Solved

how can i use getElementsByTagName with parent where conditions?

Posted on 2001-08-28
3
224 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
Comment Utility
A good idea should be to use XPath:

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

Author Comment

by:bcp5190
Comment Utility
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
Comment Utility
Oops, try:

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

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
XSD Data to SQL Tables 2 21
call javascript function from within xslt 4 26
JAXB error help 2 44
API Soap Calls 4 56
The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now