Constructor
new module:br/util/XmlParser()
Constructs a
XmlParser
. This has been included for backwards compatibility.
It is recommended that the module:br/util/XmlParser#getInstance
method is used to get an instance instead of
generating a new XmlParser
every time.
Methods
-
(static) parse(xml) → {DOMDocument}
-
Parses an XML string, stripping out any whitespace and comments, and returns a document object representation.
This method supersedes
#parseString
as it will return an XML DOM that is consistent across different browsers. All comments and unnecessary whitespace characters will be stripped out of the XML DOM.Any encoded characters within the specified string (such as
&
) will be decoded in the returnedDOMDocument
. Please seemodule:br/util/XmlUtility
for more information on character encoding in XML.Parameters:
Name Type Description xml
String The XML string to be parsed. Returns:
An XML DOM representing the specified XML. If the XML failed to be parsed an XML DOM with the root nodeparsererror
will be returned.- Type
- DOMDocument
-
(static) stripWhitespace(xml) → {String}
-
Strips out all of the unnecessary whitespace characters from the specified XML string. These are the whitespace characters stripped at the beginning and end of the string, and in between each of the tags. This makes parsing of the XML easier in Firefox which includes the whitespace within the DOM tree.
Parameters:
Name Type Description xml
String The XML to have the whitespace stripped from. - See:
Returns:
The XML with all unnecessary whitespace characters stripped out.- Type
- String