XmlParser
.
Example:
var oXmlParser = caplin.core.XmlParser; var oDocument = oXmlParser.parse("<test />"); alert(oDocument.tagName);
The caplin.core.XmlUtility singleton provides further helper methods to manipulate XML.
Attributes | Name and Description |
---|---|
|
caplin.core.XmlParser()
Constructs a |
Attributes | Name and Description |
---|---|
<static>
|
caplin.core.XmlParser
getInstance()
Gets an instance of |
<static>
|
DOMDocument
parse(String sXml)
Parses an XML string, stripping out any whitespace and comments, and returns a document object representation. |
<static>
|
DOMDocument
parseString(String sXml)
Parses an XML string and returns a document object representation. |
<static>
|
String
stripWhitespace(String sXml)
Strips out all of the unnecessary whitespace characters from the specified XML string. |
►
caplin.core.XmlParser()
Constructs a XmlParser
. This has been included for backwards compatibility.
It is recommended that the caplin.core.XmlParser#getInstance method is used to get an instance instead of
generating a new XmlParser
every time.
►
<static>
caplin.core.XmlParser
getInstance()
Gets an instance of XmlParser
. This is intended to allow a single instance to be
used throughout the application.
XmlParser
.
►
<static>
DOMDocument
parse(String sXml)
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 returned DOMDocument
. Please see caplin.core.XmlUtility for
more information on character encoding in XML.
String | sXml | The XML string to be parsed. |
parsererror
will be returned.
►
<static>
DOMDocument
parseString(String sXml)
Parses an XML string and returns a document object representation.
String | sXml | The XML string to be parsed. |
parsererror
will be returned.
►
<static>
String
stripWhitespace(String sXml)
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.
String | sXml | The XML to have the whitespace stripped from. |