Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How can i find XML list using  xmlDoc.documentElement.selectNodes?

Posted on 2001-09-05
5
Medium Priority
?
290 Views
Last Modified: 2012-06-27
<BOOKINFO>
   <BOOKNAME>xyz</BOOKNAME>
   <PUBLISHERNAME>xyz1</PUBLISHERNAME>
   <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 BOOKNAME and PUBLISHERNAME for only ENGLISH author


i'm trying something like this
Set ElemList = xmlDoc.documentElement.selectNodes("//BOOKINFO/*/AUTHORS/ENGLISH/NAME")
but how can i get name of  BOOKNAME and PUBLISHERNAME only in ElemList


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
  • 2
5 Comments
 
LVL 4

Expert Comment

by:edmund_mitchell
ID: 6458146
Hello bcp5190

Try selectNodes("/BOOKINFO/AUTHORS/ENGLISH/NAME")

HTH

Edmund
0
 

Author Comment

by:bcp5190
ID: 6458270
selectNodes("/BOOKINFO/AUTHORS/ENGLISH/NAME") will gives me all english name but i'm intrested in bookname and publisher name if any book has english authour.
i'm sorry for any confusion about question.
0
 
LVL 4

Accepted Solution

by:
sdussinger earned 100 total points
ID: 6458488
Try this:

selectNodes ("/BOOKINFO/AUTHORS[ENGLISH/NAME]/../BOOKNAME | /BOOKINFO/AUTHORS[ENGLISH/NAME]/../PUBLISHERNAME");

The problem with this approach is that it will return the PUBLISHERNAME and BOOKNAME elements in the same list. This may or may not be what you want. If you want to just get the parent node of anything which contains an english author, use this:

selectNodes ("/BOOKINFO/AUTHORS[ENGLISH/NAME]/..");

Then you can get the PUBLISHERNAME and BOOKNAME by:

bookinfoNode.selectNode ("PUBLISHERNAME");
bookinfoNode.selectNode ("BOOKNAME");

HTH

--Steve
0
 
LVL 4

Expert Comment

by:edmund_mitchell
ID: 6458494
OK
For all booknames and publisher names of any book that has an english author:
selectNodes("/BOOKINFO/BOOKNAME[following-sibling::AUTHORS[1]/ENGLISH/NAME] | /BOOKINFO/PUBLISHERNAME[following-sibling::AUTHORS[1]/ENGLISH/NAME]")

should do the trick.

I hope that answers your question, but if not, just let us know.

Edmund
0
 

Author Comment

by:bcp5190
ID: 6461374
last answer is also correct but i don't know how to give point to both of you. sorry and thanks to all of you.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
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.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

636 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