Class AjxXmlDoc
Method Detail
<static>
{AjxXmlDoc}
AjxXmlDoc.create()
Creates an XML doc.
<static>
{AjxXmlDoc}
AjxXmlDoc.createElement(name, value)
Creates an XML document with the element.
<static>
{AjxXmlDoc}
AjxXmlDoc.createFromDom(doc)
Creates an XML doc from a document object.
<static>
{AjxXmlDoc}
AjxXmlDoc.createFromXml(xml)
Creates an XML doc from an XML string.
<static>
{AjxXmlDoc}
AjxXmlDoc.createRoot(rootName)
Creates an XML document with a root element.
{Document}
getDoc()
Gets the document.
<static>
{string}
AjxXmlDoc.replaceInvalidChars(s)
Replaces invalid characters in the given string.
toJSObject(dropns, lowercase, withAttrs)
This function tries to create a JavaScript representation of the DOM. In some cases,
it is easier to work with JS objects rather than do DOM lookups.
Rules:
<error> <code>404</code> <name>Not Found</name> <description>Page wasn't found on this server.</description> </error> var obj = AjxXmlDoc.createFromXml(XML).toJSObject(); alert(obj.code + " " + obj.name + " " + obj.description);Here's an array example: <return> <item> <name>John Doe</name> <email>foo@bar.com</email> </item> <item> <name>Johnny Bravo</name> <email>bravo@cartoonnetwork.com</email> </item> </return> var obj = AjxXmlDoc.createFromXml(XML).toJSObject(); for (var i = 0; i < obj.item.length; ++i) { alert(obj.item[i].name + " / " + obj.item[i].email); }Note that if there's only one <item> tag, then obj.item will be an object rather than an array. And if there is no <item> tag, then obj.item will be undefined. These are cases that the calling application must take care of.
|
||||||||||||||||||||||
Documentation generated by JsDoc Toolkit 2.3.0 on Tue Jun 28 2016 21:01:30 GMT-0400 (EDT)
|