@
namespaceXML
object from a string:var order = new XML("<order/>");
XML
wrapper for a DOM object:var doc = new XML(document);
<order id="1234">
<customer><name>Joe Green</name>
<address><street>410 Main</street>
<city>York</city><state>VT</state>
</address>
</customer>
<item>. . .</item>
<item>
<make>Acme</make>
<model>Framistat</model>
<price>2.50</price>
<qty>30</qty>
</item>
</order>
var address = order.customer.address;
var second = order.item[1];
second.total = second.qty * second.price;
var order = <order><customer>. . .</customer>
<item><price>5</price><qty>10</qty></item>
<item level="rush">
<price>2.5</price>
<qty>30</qty>
</item>
<item level="rush">
<price>1.5</price>
<qty>50</qty>
</item>
</order>;
var items = order.item; // XMLList of item el'ts
var prices = order..price;
var urgentItems = order.item.(@level == "rush");
var itemAttrs = order.item[0].@*;
order.customer.address = <address><street>...</street></address>;
order.item += <item level={++urgency}/>
order.customer.name = <prefix>{prefix[i]}</prefix>
fully_dynamic = <{tagname}>{content}</{tagname}>;
tagname
must be a valid XML namenew QName(uri, localName);
var n1 = new Namespace([prefix, ]uri1);
x = <t xmlns:p="uri1">
<p:u>42</u>
<p:not-an-identifier id="99"/>
<t>;
y = x.n1::u; // y == 42
i = x.n1::["not-an-identifier"].@id;
*
=> undefined
@oops
=> undefined
@*::*
=> undefined
..
to homogenizevar html = <html/>; html.head.title = "My Page Title"; html.body.@bgcolor = "#e4e4e4"; html.body.form.@name = "myform"; html.body.form.@action = "someurl.jss"; html.body.form.@method = "post"; html.body.form.@onclick = "return somejs();"; html.body.form.input[0] = ""; html.body.form.input[0].@name = "test";
<html> <head> <title>My Page Title</title> </head> <body bgcolor="#e4e4e4"> <form name="myform" action="someurl.jss" method="post" onclick="return somejs();"> <input name="test"></input> </form> </body> </html>
with
m = x.toXMLString;
and call m later
m = x.function::toXMLString
for this