Solved

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

Posted on 2001-09-05
5
281 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

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…
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.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 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

20 Experts available now in Live!

Get 1:1 Help Now