XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
David ChanSubject: xpath question
Author: David Chan
Date: 13 Feb 2006 03:06 PM
Hi all,

For example, my xml

</SQLResultSet>
…..

1</RowsAffected>
</SQLResult>
<SQLResult>
<RowsAffected ParameterRow="0" >
1</RowsAffected>
</SQLResult>
<SQLBatchResult>
<case>5</case>
</SQLBatchResult>
</SQLResultSet>

How can I use xpath to get "5" only?

Regards
Dave

Posttop
(Deleted User) Subject: xpath question
Author: (Deleted User)
Date: 13 Feb 2006 04:10 PM
Hi, David. I'm not sure if I completely understand your question, so here are two possible interpretations, with two answers:

If you're looking for whatever value is contained in the <case> subelement, then a simple //case XPath statement will return that value.

If, however, you're looking only for those instances where <case> is 5, then you want to use this: //SQLBatchResult[case=5]

By the way, the XML snippet you provided wasn't well-formed, so I took the liberty of making sure it was (this made it possible to test different XPath statements):

<?xml version="1.0"?>
<SQLResultSet>
<SQLResult>
<RowsAffected>…..

1</RowsAffected>
</SQLResult>

<SQLResult>
<RowsAffected ParameterRow="0">1</RowsAffected>
</SQLResult>

<SQLBatchResult>
<case>5</case>
</SQLBatchResult>
</SQLResultSet>


David Foster
Stylus Studio Team

 
Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.