xml Attributes

  • Thread starter Thread starter daveL
  • Start date Start date
D

daveL

Hi i have a Xml looks like below, im trying to get a Attribute from a inner
xml portion
Example:

<Root>
<Node1>
<Node2 Enabled="No">
<Node3>somevalue<Node3>
</Node2>
</Node1>
</Root>

my code
XmlNode node =doc.Root.SelectSingleNode("Node1/Node2[@Name='Enabled']");
node is null

What am i doing Wrong

Thanks DaveL
 
Ignoring the missing / in </Node3>, you are asking for the Node2
element with an attribute called "Name" with value "Enabled" - what
you should be asking about is [@Enabled='No'], or [@Enabled='Yes] (to
check for specific values), or just [@Enabled] to just check for the
existence of an attribute called "Enabled".

If this doesn't do what you want, please indicate which node you want
to select...

Marc
 
Thanks Marc...
guess had my head on backwards...
have a gr8 dave
DaveL
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top