Loading a Document with the XDocument.Load Method with LoadOptions : XDocument : XML LINQ C# Source Code


Custom Search

C# Source Code » XML LINQ » XDocument »

 

Loading a Document with the XDocument.Load Method with LoadOptions








    
 

using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using System.Xml.Linq;
public class MainClass {
    public static void Main() {
        XDocument xDocument = XDocument.Load("book.xml",LoadOptions.SetBaseUri | LoadOptions.SetLineInfo);
        Console.WriteLine(xDocument);
        XElement firstName = xDocument.Descendants("FirstName").First();

        Console.WriteLine("FirstName Line:{0} Position:{1}",((IXmlLineInfo)firstName).LineNumber,((IXmlLineInfo)firstName).LinePosition);
        Console.WriteLine("FirstName Base URI:{0}", firstName.BaseUri);

    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo XML LINQ
» XDocument