RE: RE: linking and DOM
Thanks But if I have another file c.xml which has the same Date element ID as in B, I would be confused which one to read? How can I make sure I want only b.xml not c.xml? Is xpointer useful?. I have no idea on this! > >-----Original Message----- > >From: Mike Champion [mailto:mc@x...] > >Sent: Tuesday, July 16, 2002 4:49 PM > >To: 'Xml-Dev (E-mail)' > >Subject: 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. > > > > > > > > > > > > > >----------------------------------------------------------------- > >The xml-dev list is sponsored by XML.org <http://www.xml.org>, an > >initiative of OASIS <http://www.oasis-open.org> > > > >The list archives are at http://lists.xml.org/archives/xml-dev/ > > > >To subscribe or unsubscribe from this list use the subscription > >manager: <http://lists.xml.org/ob/adm.pl> > >
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