Load and parse

Load and parse Xml documentation from a file by using XElement


using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;

class Program
{
    static void Main()
    {
        XElement fromFile = XElement.Load(@"e:\somefile.xml"); 
    }
}

Load and parse Xml documentation from a Uri


using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;

class Program
{
    static void Main()
    {
        XDocument fromWeb = XDocument.Load("http://your domain.com/sample.xml");
    }
}

Use XElement to parse an Xml string

 

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;

class Program
{
    static void Main()
    {
        string xml = @"<Root><client enabled='false'><timeout>60</timeout></client></Root>";

        XElement customer = XElement.Parse(xml);
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.