Mean, sick, and poor is no way to go through life, son.

Need a good from the ground up tutorial for XML DOM with

specific attention to navigating it with javascript.

Permalink Mark Warner 
January 19th, 2006
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


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?
Permalink Mark Warner 
January 19th, 2006
Yes you can, look up XPath rules (then lookup documentation to set the right sort of XPath in MSXML :-)
Permalink Erik Springelkamp 
January 19th, 2006

MyNode.SelectSingleNode("//*[@ID = 42]")

will probably do the trick (but I never used it myself).
Permalink Erik Springelkamp 
January 19th, 2006
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).
Permalink slava 
January 19th, 2006
Well the syntax is fucking horrible, but DTDs I can actually understand and at least get my head around.
Permalink Generic Error 
January 20th, 2006

This topic was orginally posted to the off-topic forum of the
Joel on Software discussion board.

Other topics: January, 2006 Other topics: January, 2006 Recent topics Recent topics