Question

Hello I am working on XmlDocument retrieval

part of my document is

 <Product ID="102166"> 
        <Name>Name1</Name> 
         <Mrp>220.0000</Mrp> 
         <Price>210.2800</Price> 
          <Cost>177.8700</Cost> 
         <Barcode>102166,10216610,8901786409990,9910216600011,10216620,9910216600202
    </Barcode>
 </Product> 

I want to select single product node from document whose itemcode inner text contains given string

e.g If I give 8901786409990 as input output should be its parent i.e. Product with ID 102166

I have tried following with no success

string ItemCode="8901786409990 ";
 XmlNode node = doc.SelectSingleNode("/*/b:Product[contains(b:Barcode,'" + Itemcode1 + "')");

It throws exception '/*/b:Product[contains(b:,'8901786409990')' has an invalid token.

Any Help?

Was it helpful?

Solution

You are missing a close bracket:

string ItemCode="8901786409990 ";
 XmlNode node = doc.SelectSingleNode("/*/b:Product[contains(b:Barcode,'" + Itemcode1 + "')]");

See the extra bracket here:

'/*/b:Product[contains(b:,'8901786409990')]'

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top