For example,
<p:a xmlns:p="<http://example.com/p>">
Text 1
<p:b att1="one" att2="two">
<q:a xmlns:q="<http://example.com/q>" p:att3="three">
Text 2
</q:a>
</p:b>
Text 3
</p:a>
is represented as (ignoring whitespace):
xml.elementNode({
name: "p:a",
space: "<http://example.com/p>",
prefix: "p",
local: "a",
props: {},
children: [
xml.textNode("Text 1"),
xml.elementNode({
name: "p:b",
space: "<http://example.com/p>",
prefix: "p",
local: "b",
props: {
"att1": { name:"att1", space:"", prefix:"", local:"att1", value:"one" },
"att2": { name:"att1", space:"", prefix:"", local:"att2", value:"two" }
},
children: [
xml.elementNode({
name: "q:a",
space: "<http://example.com/p>",
prefix: "q",
local: "a",
props: {
"p:att3": { name:"p:att3", space:"<http://example.com/p>", prefix:"p", local:"att3", value:"three" }
}.
children: [ xml.textNode("Text 2") ]
})
]
}),
xml.textNode("Text 3")
]
})
Notes:
xmlns attributes are not represented as such in the tree. They are removed by the parser, and the namespace information is only represented by the space fields. The formatter adds xmlns attributes back.name and space are authoritative. prefix and local are just entered by the parser for convenience, and are directly taken from name. The formatter only looks at name and space.space is the empty string, the element or attribute is outside any namespacehttp://example.com/p to the prefix abc, this prefix will appear in the tree even if the XML text uses pprops: { att1: "one" }. In this case, however, no namespace can be used.