tags:

views:

27

answers:

3

I need to retrieve all of these types of nodes: <parameter value="thisisthename" name="parameters" /> where type = MyTest and one of the child <parameter value="c:\temp\svn.exe" name="file" /> equals c:\temp\svn.exe

Right now I have

ert[type='MyTest']/parameters/parameter[@value='c:\temp\svn.exe']

  <ert agents="0031">
  <type>MyTest</type> 
  <parameters>
  <parameter value="c:\temp\svn.exe" name="file" /> 
  <parameter value="thisisthename" name="parameters" /> 
  <parameter value="200" name="count" /> 
  </parameters>
  </ert>
A: 

I go back to this site whenever I have XPath questions...hopefully it helps you.

http://www.w3schools.com/XPath/xpath_syntax.asp

Jamie
+1  A: 

You are almost there. This is the XPath expression you're looking for:

/ert[type='MyTest']/parameters/parameter[@value='c:\temp\svn.exe']/../parameter[@value='thisisthename']

The idea is that you can move up the xml tree using /...

If you happen to know that c:\temp\svn.exe is always somewhere before the parameter node you want, you could also use:

/ert[type='MyTest']/parameters/parameter[@value='c:\temp\svn.exe']/following-sibling::parameter[@value='thisisthename']

This may be a little faster since no backtracking will occur.

Ronald Wildenberg
ahh! awesome! did not know thatthank you
If this is the answer you were looking for, could you mark it as answered?
Ronald Wildenberg
A: 

I need to retrieve all of these types of nodes: <parameter value="thisisthename" name="parameters" /> where type = MyTest and one of the child <parameter value="c:\temp\svn.exe" name="file" /> equals c:\temp\svn.exe

All this three conditions, in Xpath:

/ert[type='MyTest']
    [parameters/parameter[@value='c:\temp\svn.exe']]
    /parameters/parameter[@value][@name]

This means: from an ert root element having a type child with "MyTest" string value and a parameters/parameter grandchild with value attribute equal to "c:\temp\svn.exe", I want all parameters/parameter grandchidren having value and name attributes.

Alejandro