Csharp/C Sharp/XML/Tag

Материал из .Net Framework эксперт
Перейти к: навигация, поиск

Get XML Elements By Tag Name

<source lang="csharp"> using System; using System.Xml; public class FindNodesByName {

   private static void Main() {
       // Load the document.
       XmlDocument doc = new XmlDocument();
       doc.Load("books.xml");
       // Retrieve all prices.
       XmlNodeList nodeList = doc.GetElementsByTagName("B");
       foreach (XmlNode node in nodeList) {
           Console.WriteLine(node.ChildNodes[0].Value);
       }
   }

} // books.xml /* <books>

 <A property="a">
   text
   <C>textg</C>
   <D>99999</D>
 </A>

</books>

  • /
      </source>