Solved

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

Posted on 2001-09-05
5
282 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
  • 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 25 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

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 …
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, …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

777 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