specific attention to navigating it with javascript.
Help?
Need a good from the ground up tutorial for XML DOM withspecific attention to navigating it with javascript.
Help? basically I just want to be able to take the documentElement from an XMLHttpRequest response object and then use getElementById() to find specific elements in that document
BUT I'm pretty sure I need a DTD someplace that defines a specific attribute as an ID, no? I can't just throw an attribute in there named 'id' and expect it to work, right? Yes you can, look up XPath rules (then lookup documentation to set the right sort of XPath in MSXML :-)
http://www.w3.org/TR/xpath
MyNode.SelectSingleNode("//*[@ID = 42]") will probably do the trick (but I never used it myself). XPath is your friend. The one Erik gave would work. You can track down any attributes (and combinations) as you wish with it.
I think the XML unique id business is mainly for optimization - XML equivalent to SQl's indices (that's my take). If you really like DTDs, something like this would probably work ... <!DOCTYPE root [ <!ELEMENT myElement (ANY)> <!ATTLIST myElement myAttribute ID ""> ]> Then you can use the XPath, "id('42')" to grab a node like <myElement myAttribute='42'/>. But DTDs are a pain in the butt (even Tim Bray thinks so). Well the syntax is fucking horrible, but DTDs I can actually understand and at least get my head around.
|
|
|
|
|