Add a program to install fars.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2276 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -16,12 +16,12 @@ import xml.dom.minidom
|
||||
|
||||
def XmlList(Dom, String):
|
||||
"""Get a list of XML Elements using XPath style syntax."""
|
||||
if String == "" :
|
||||
return []
|
||||
if Dom.nodeType==Dom.DOCUMENT_NODE:
|
||||
return XmlList(Dom.documentElement, String)
|
||||
if String[0] == "/":
|
||||
return XmlList(Dom, String[1:])
|
||||
if String == "" :
|
||||
return []
|
||||
TagList = String.split('/')
|
||||
nodes = []
|
||||
if Dom.nodeType == Dom.ELEMENT_NODE and Dom.tagName.strip() == TagList[0]:
|
||||
@ -33,6 +33,14 @@ def XmlList(Dom, String):
|
||||
nodes = nodes + XmlList(child, restOfPath)
|
||||
return nodes
|
||||
|
||||
def XmlNode (Dom, String):
|
||||
"""Return a single node that matches the String which is XPath style syntax."""
|
||||
try:
|
||||
return XmlList (Dom, String)[0]
|
||||
except:
|
||||
return None
|
||||
|
||||
|
||||
def XmlElement (Dom, String):
|
||||
"""Return a single element that matches the String which is XPath style syntax."""
|
||||
try:
|
||||
@ -88,6 +96,19 @@ def XmlParseFileSection (FileName, Tag):
|
||||
except:
|
||||
return xml.dom.minidom.parseString('<empty/>')
|
||||
|
||||
def XmlParseStringSection (XmlString, Tag):
|
||||
"""Parse a section of an XML string into a DOM(Document Object Model) and return the DOM."""
|
||||
Start = '<' + Tag
|
||||
End = '</' + Tag + '>'
|
||||
File = XmlString
|
||||
if File.find(Start) < 0 or File.find(End) < 0:
|
||||
return xml.dom.minidom.parseString('<empty/>')
|
||||
File = File[File.find(Start):File.find(End)+len(End)]
|
||||
try:
|
||||
return xml.dom.minidom.parseString(File)
|
||||
except:
|
||||
return xml.dom.minidom.parseString('<empty/>')
|
||||
|
||||
def XmlSaveFile (Dom, FileName, Encoding='UTF-8'):
|
||||
"""Save a DOM(Document Object Model) into an XML file."""
|
||||
try:
|
||||
|
Reference in New Issue
Block a user