OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] RE: linking and DOM

[ Lists Home | Date Index | Thread Index ]

7/16/2002 4:30:14 PM, "Yallala, Bhaskar" <B_Yallala@DirectAdvice.com> 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.

 







 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS