Solved

how can i use getElementsByTagName with parent where conditions?

Posted on 2001-08-28
3
230 Views
Last Modified: 2008-03-06
<BOOKINFO>
    <NAME>xyz</NAME>
    <AUTHORS>
         <ENGLISH>
             <NAME>name1</NAME>
         <ENGLISH>
         <SPANISH>
             <NAME>name2</NAME>
         </SPANISH>
    </AUTHORS>
</BOOKINFO>

I have xml string similiar to shown as above now
using DOM how can i find name of the author if BOOKINFO.NAME = "xyz"

First choice should be english authour if not only then spenish author

i'm trying something like this
Set ElemList = xmlDoc.getElementsByTagName("NAME")
but how can i have name of the authors for only xyz book

or is there any other way i can do this?
0
Comment
Question by:bcp5190
  • 2
3 Comments
 
LVL 4

Expert Comment

by:chabaud
ID: 6435850
A good idea should be to use XPath:

Set ElemList = xmlDoc.documentElement.selectNodes("//BOOKINFO/Name['xyz']/AUTHORS//NAME")
0
 

Author Comment

by:bcp5190
ID: 6436565
i try it but didn't work i think because AUTHORS is not child of NAME .
AUTHORS is child of BOOKINFO
0
 
LVL 4

Accepted Solution

by:
chabaud earned 50 total points
ID: 6436643
Oops, try:

//BOOKINFO[Name='xyz']/AUTHORS//NAME
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
XML Parsing Classic ASP 5 74
How can I assign SimpleXMLElements to variables? 5 71
Test ddwrt:UserLookup 1 71
SQL Result Set to XML 4 50
The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question