Select on multiple criteria with XPath

后端 未结 3 1529
时光取名叫无心
时光取名叫无心 2020-12-17 08:46

I have an XML document which looks something like this:


 
  MENSWEAR 
  

        
3条回答
  •  臣服心动
    2020-12-17 09:08

    or you could use linq to XML and do it like this :

    var match = XElement.Parse(xmlString);
    
    var matches = from xml in xmlDocument.Elements()
                  where xml.Element("comp_div").Value == "MENSWEAR"
                  && xml.Element("sty_ret_type").Value == "ACCESSORIES"
                  && xml.Element("sty_pdt_type").Value == "BELTS"
                  && xml.Element("pdt_category").Value == "AWESOME_BELTS"
                  select xml;
    

提交回复
热议问题