Get Xmlnode by an attribute

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

Im trying to get a xmlnode having the value of an attribute, but without
success

this is my xml file:
<promotions>
<promotion id="0">
<image>images/gifs/Panel4/Panel4_Prom2.gif</image>
<text>Text of promotión 1</text>
</promotion>
<promotion id="1">
<image>images/gifs/Panel4/Panel4_Prom2.gif</image>
<text>Text of promotión 1</text>
</promotion>
<promotion id="2">
<image>images/gifs/Panel4/Panel4_Prom2.gif</image>
<text>Text of promotión 1</text>
</promotion>
<promotioninuse>1</promotioninuse>
</promotions>

First i take the Promotion to use from the node <promotioninuse> like this
(until here no problem):
XmlNode PromotioninUse=RootNode.SelectSingleNode("promotioninuse");
string id=PromotioninUse.InnerText;

My problem comes where i try to get the node that have an attribute with the
value in this case "1" (promotion in use)

but this code doesnt work:

XmlNode PromotionData=RootNode.SelectSingleNode("promotion[id]");

How could i get the correct promotion...
 
Back
Top