xpath question
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 2
- Joined: Fri Feb 24, 2006 10:42 pm
xpath question
here's my xml:
returns three nodes: two "left" nodes and one "right" node.
/xml//*[@x='y']
returns the two "left" nodes:
/xml//*[@x='y'][1]
returns the "right" node:
/xml//*[@x='y'][2]
returns nothing:
/xml//*[@x='y'][3]
Is there a way i can structure the first query (that returns all three nodes) in such a way that appending the position predicates [1],[2],[3] results in three queries that each uniquely identify a single node?
thanks!
-w
Code: Select all
<xml>
<base>
<left x="y"></left>
<middle></middle>
<right>
<left x="y"></left>
<middle></middle>
<right x="y"></right>
</right>
</base>
</xml>
/xml//*[@x='y']
returns the two "left" nodes:
/xml//*[@x='y'][1]
returns the "right" node:
/xml//*[@x='y'][2]
returns nothing:
/xml//*[@x='y'][3]
Is there a way i can structure the first query (that returns all three nodes) in such a way that appending the position predicates [1],[2],[3] results in three queries that each uniquely identify a single node?
thanks!
-w
-
- Posts: 2
- Joined: Fri Feb 24, 2006 10:42 pm
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Hi,
A side note to your post: it is bad practice to use the names starting with xml as you did. It is not an error but these are reserved names, see
http://www.w3.org/TR/2004/REC-xml-20040 ... common-syn
George
A side note to your post: it is bad practice to use the names starting with xml as you did. It is not an error but these are reserved names, see
http://www.w3.org/TR/2004/REC-xml-20040 ... common-syn
Best Regards,Names beginning with the string "xml", or with any string which would match (('X'|'x') ('M'|'m') ('L'|'l')), are reserved for standardization in this or future versions of this specification.
George
Return to “General XML Questions”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service