C# How to extract complete xml node set

后端 未结 4 566
名媛妹妹
名媛妹妹 2021-01-15 12:30

 
   
    Everyday Italian         


        
4条回答
  •  萌比男神i
    2021-01-15 13:14

    Let's say this XML is stored in an XmlDocument called doc.

    XmlElement docRoot = doc.DocumentElement;
    XmlNode cookingNode = docRoot.SelectSingleNode("./book[@category='COOKING']");
    

    I tested this and added this line to verify:

    Console.WriteLine(cookingNode.OuterXml);
    

    Here was the output:

    Everyday ItalianGiada
    De Laurentiis200530.00
    

提交回复
热议问题