Re: RE: linking and DOM
7/16/2002 4:30:14 PM, "Yallala, Bhaskar" <B_Yallala@D...> wrote: >> > <Date Interval> >> > <start><Date>xyz</Date></<start> >> > <limit><Date>pqr</Date></<limit> >> > </Date Interval> >> > >> >And I have another file called b.xml, in which Date with ID= >> >xyz is present. >> > >> >How can I parse this using DOM and how can I refer in a.xml >> >, how to goto b.xml's xyz ID? Load a and b in separate DOM Document objects A and B. Extract the value of the element or attribute in A that you want to look up in B into a variable, call it "x". Then pass "x" to B's getElementById() method on B. You'll get back an Element object where it's ID attribute has the value contained in X. You will need to declare that the Date elment has an ID attribute called ID in a DTD or Schema governing B, or getElementById can't work. One nice thing about HTML/XHTML is that their DOMs understand that "id" is an "ID" attribute without you having to tell it. Of course, if there are multiple Date elements with an ID value equal to the value of x, then undefined and unpleasant things will happen ...but a validating parser would warn you of that. I don't know if most HTML/XHTML browsers will warn you or not... By the way, getElementById() is defined in DOM LEvel 2, so not all DOM implementations will support it.
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format