xpath related resources

Hi,

In my project extensive XPATH is being used. I wonder what are best links, resources, books, source code, sample project to become master in XPATH, XML related areas. Please advise
LVL 7
gudii9Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Carl TawnSystems and Integration DeveloperCommented:
XPath wise the W3Schools tutorials provide a comprehensive introduction:  http://www.w3schools.com/xpath/

Plus they have a reference guide for the available XPath functions.

Of course the W3C is the ultimate reference, but it's a bit of a dry read: http://www.w3.org/TR/xpath/

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gudii9Author Commented:
any other good link or resource apart from w3schools to run and execute sameple programs on my eclipse IDE and see the concepts with working code. Please advise
Carl TawnSystems and Integration DeveloperCommented:
There are countless tutorials kicking around, which a quick Google search will point you to.

Another example being:

    http://www.tutorialspoint.com/xpath/

Or this video is specifically targeted at using XPath in Eclipse:

     https://www.youtube.com/watch?v=sqKDri4ixsU

There is also this little tool available for testing XPath queries in isolation:

    http://www.freeformatter.com/xpath-tester.html
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

gudii9Author Commented:
1. Select the document node
/
2. Select the 'root' element
/root
3. Select all 'actor' elements that are direct children of the 'actors' element.
/root/actors/actor
4. Select all 'singer' elements regardless of their positions in the document.
//foo:singer
5. Select the 'id' attributes of the 'singer' elements regardless of their positions in the document.
//foo:singer/@id
6. Select the textual value of first 'actor' element.
//actor[1]/text()
7. Select the last 'actor' element.
//actor[last()]
8. Select the first and second 'actor' elements using their position.
//actor[position() < 3]
9. Select all 'actor' elements that have an 'id' attribute.
//actor[@id]
10. Select the 'actor' element with the 'id' attribute value of '3'.
//actor[@id='3']
11. Select all 'actor' nodes with the 'id' attribute value lower or equal to '3'.
//actor[@id<=3]
12. Select all the children of the 'singers' node.
/root/foo:singers/*
13. Select all the elements in the document.
//*
14. Select all the 'actor' elements AND the 'singer' elements.
//actor|//foo:singer
15. Select the name of the first element in the document.
name(//*[1])
16. Select the numeric value of the 'id' attribute of the first 'actor' element.
number(//actor[1]/@id)
17. Select the string representation value of the 'id' attribute of the first 'actor' element.
string(//actor[1]/@id)
18. Select the length of the first 'actor' element's textual value.
string-length(//actor[1]/text())
19. Select the local name of the first 'singer' element, i.e. without the namespace.
local-name(//foo:singer[1])
20. Select the number of 'singer' elements.
count(//foo:singer)
21. Select the sum of the 'id' attributes of the 'singer' elements.
sum(//foo:singer/@id)

Open in new window

i like the last link

i wonder why some xpath examples starting with / and some other with // as above. please advise
Carl TawnSystems and Integration DeveloperCommented:
The single slash means "child" of, whereas double-slash means "descendent" of.

So, for example, "root/childnode" would find a "childnode" element that is a direct child of "root". Whereas, "root//childnode" would find a "childnode" that is a descendent of "root", no matter how many levels deep.

A more verbose example:
<?xml version="1.0" encoding="iso-8859-1"?>
<root>
    <child>Hello</child>
    <level>
       <child>World</child>
    </level>
</root>

Open in new window

With the XML above "root/child" would only match the "child" node with a value of 'Hello'. "root//child" would match both child nodes ("Hello" and "World")

Hope that makes sense.
gudii9Author Commented:
With the XML above "root/child" would only match the "child" node with a value of 'Hello'. "root//child" would match both child nodes ("Hello" and "World")

Hope that makes sense.

It is very clear now and i see decendent is much powerful in real world applications.  So it is not avisable to use // decendent all the time since that cover child alreeady in that?

Please advise
Carl TawnSystems and Integration DeveloperCommented:
Not really.  "//" is slower because it has to search the whole tree. The more specific you can be in your XPath query the better.
gudii9Author Commented:
what are best 3 books on xml , xsd, xslt, xpath etc related areas which is crux of all programming languages including java  c++ etc
Carl TawnSystems and Integration DeveloperCommented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
XML

From novice to tech pro — start learning today.