XML : XPath - Selecting xml nodes with attributes with names that follow pattern

I'm trying to select all the nodes in an xml doc that have attributes with a certain naming pattern using XPath 1.0.

sample XML:

  <Foo>      <Bar id="1234">          <Attributes foo_attrib1="foo" foo_attrib2="bar"/>      </Bar>      <Bar id="2345">          <Attributes foo_attrib3="foobar"/>      </Bar>      <Bar id="3456"/>  </Foo>    

The query i'm using is this:

  /Foo/Bar/Attributes[starts-with(name(),'foo']    

It seems like this should work, but I'm not getting any nodes returned with this query. Seems like this should also be a pretty simple query, so I'm sure I'm just messing something obvious up.

Thanks in advance for any help!

No comments:

Post a Comment