Click to See Complete Forum and Search --> : [RESOLVED] A little XPath Help please


shotsy247
09-03-2009, 07:20 AM
Hi All,

I have an XML document that looks like this:

<features>
<featureSet>
<description>Application Features</description>
<feature>
<description>Some Description</description>
<standard>true</standard>
<preferred>true</preferred>
<professional>true</professional>
<legal>true</legal>
</feature>

<feature>
<description>Some Description</description>
<standard>true</standard>
<preferred>true</preferred>
<professional>true</professional>
<legal>true</legal>
</feature>
</featureSet>

<featureSet>
<description>Extra Features</description>
<feature>
<description>Some Description</description>
<standard>true</standard>
<preferred>true</preferred>
<professional>true</professional>
<legal>true</legal>
</feature>

<feature>
<description>Some Description</description>
<standard>true</standard>
<preferred>true</preferred>
<professional>true</professional>
<legal>true</legal>
</feature>
</featureSet>
</features>

I am able to iterate through the various featureSet description texts and would like use those values to select all of the feature nodes of any given featureSet. What would the XPath look like to accomlish this?

Thanks in advance.

_t

Scriptage
09-03-2009, 08:05 AM
Your question is pretty vague, can you give an example input and expected output?

shotsy247
09-03-2009, 09:41 AM
Sorry I didn't think it was vague. I'll try to restate.

I want to return all of the feature nodes within a the featureSet where the description matches the string I provide.

I'm using ASP to accomplish this so the code goes something like:

<% set f = FXML.selectNodes( "//features/featureSet/feature[ contains( //features/featureSet/description, '" & FSD.text & "' ) ]" ) %>

Where FXML is the xml root and FSD.text is the value of one of the featureSet/description nodes.

I hope this helps

*Edit

I found the solution. In my case I already had all of the featureSet nodes, so I just had to select the feature nodes from each featureSet node.

The code is this:

<% for each i in FSNodes %>
<% dim FSD, f %>
<% set FSD = i.selectSingleNode( "description" ) %>
<% set f = i.selectNodes( "feature" ) %>
<%next %>

shotsy247
09-03-2009, 10:03 AM
ooops mistake post