PDA

View Full Version : XMLPath question


paul.d.mcswain
07-31-2009, 01:47 PM
When using the XML.GetAttribute/SetAttribute, I'm getting an error when I specify a path of "/configuration/appSettings/add[1]" it gives an error.

I'm pretty sure that this is a valid XPath statement for the following XML:

<configuration>
<appSettings>
<add key="blah" value="fred was here" />
<add key="yabba" value="wilma was here" />
<add key="dabba" value="barney was here" />
</appSettings>
</configuration>

What am I doing incorrectly?
Thanks
Paul.

AdrianS
08-01-2009, 06:25 AM
The XML paths in SU8 use a slightly different syntax. What you need is

"configuration/appSettings/add:1"

Note that there's no leading slash, since the path is always assumed to start from the root.