[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

XPath

Posted on 2013-11-01
2
Medium Priority
?
324 Views
Last Modified: 2013-11-03
Hello, might someone explain to me what this paragraph is saying about "/";
Which is the right of / ?  For example: 1/2, I consider 2 to be to the right of /.  Is this the way it is used in the explanation below?:
http://en.wikipedia.org/wiki/XPath_2.0
Path expressions[edit]

The location paths of XPath 1.0 are referred to in XPath 2.0 as path expressions. Informally, a path expression is a sequence of steps separated by the "/" operator, for example a/b/c (which is short for child::a/child::b/child::c). More formally, however, "/" is simply a binary operator that applies the expression on its right-hand side to each item in turn selected by the expression on the left hand side. So in this example, the expression a selects all the element children of the context node that are named <a>; the expression child::b is then applied to each of these nodes, selecting all the <b> children of the <a> elements; and the expression child::c is then applied to each node in this sequence, which selects all the <c> children of these <b> elements.
0
Comment
Question by:chima
[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 Comments
 
LVL 51

Accepted Solution

by:
Mark Wills earned 2000 total points
ID: 39618671
Not sure I understand your question...

XPATH basically provides a "tree" representation of an XML document... Meaning we can interrogate an XML document via referencing the Nodes directly.

 Which means that path expressions represents the locations within the tree. The expressions are relative and each path is separated by the "/". So think of the path as pointing to a particular node.

Lets take the example of :
<cars>

 <car>
   <make>Ferrari</make>
   <price>500000.00</price>
 </car>

 <car>
   <make>Lamborghini</make>
   <price>600000.00</price>
 </car>

 <car>
   <make>Pagani</make>
   <price>700000.00</price>
 </car>

</cars> 

Open in new window


To select (or point to) all the makes, then the Path would be :
/cars/car/make

To return the actual text of all makes,  then the Path would be :
/cars/car/make/text()

So the right hand side of the "/" has the expression of what the xpath is referring to.  Or really what it needs to do with the nodes as referenced on the left. In the first example above, it is the node "make" in the second example the expression is asking for the actual values (the text() expression).

Take the example of :
/cars/car[price>500000]/make/text()

that's got an expression car[price>500000] that is used to select car nodes with a price > 500000 and then goes on to get the text value of the "make"

When going through these types of examples, always best to start with a sample XML document.

See the W3 standards : http://www.w3.org/TR/xpath20/#id-path-expressions

Or use the tutorials : http://www.w3schools.com/xpath/default.asp

Using the above rather than wiki should / might make it easier for you.
0
 

Author Closing Comment

by:chima
ID: 39620436
Good explanation.  I started to read the "specification" and then thought this is "useless."  I needed some examples or tutorial.  I found the 3WC tutorial.
I got another question asked.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Suggested Courses

649 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