[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: RE: linking and DOM


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!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.