Solved

how can i use getElementsByTagName with parent where conditions?

Posted on 2001-08-28
3
235 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

688 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