XElement.Parse(String xml value) : XElement « System.Xml.Linq « C# / C Sharp by API






XElement.Parse(String xml value)

   


using System;
using System.Linq;
using System.Xml.Linq;

public class MainClass {
    public static void Main() {

        XElement books = XElement.Parse(
          @"<books>
        <book>
          <title>P</title>
          <author>J</author>
        </book>
        <book>
          <title>W</title>
          <author>B</author>
        </book>
        <book>
          <title>C</title>
          <author>A</author>
        </book>
    </books>");

        var titles =
         from book in books.Elements("book")
         where (string)book.Element("author") == "J"
         select book.Element("title");

        foreach (var title in titles)
            Console.WriteLine(title.Value);
    }
}

   
    
    
  








Related examples in the same category

1.new XElement
2.XElement.AddFirst
3.XElement.Ancestors()
4.XElement.AncestorsAndSelf()
5.XElement.AncestorsAndSelf(String tagName)
6.XElement.Attribute
7.XElement.Changed
8.XElement.Changing
9.XElement.Descendants
10.XElement.Descendants("firstname").First()
11.XElement.Elements
12.XElement.First
13.XElement.FirstAttribute
14.XElement.GetSchemaInfo()
15.XElement.HasAttributes
16.XElement.HasElements
17.XElement.Load(String fileName)
18.XElement.Nodes()
19.XElement.Parent
20.XElement.Remove
21.XElement.RemoveAll
22.XElement.Save(String fileName)
23.XElement.SetAttributeValue
24.XElement.SetElementValue