How to

load xml document

Published: 14. January 2009 | Updated: 26. October 2011
License: Microsoft Public License (MS-PL)
Categories: Streams, Framework » XML
Tags: C# XML
Was this snippet helpful for you? YESYES / NONO
Get Analyzant!

Check your entire website from code to content in minutes with Analyzant, the free analysis suite.

Free download at analyzant.com

Import namespaces

using System.IO;
using System.Xml;

Code

// create instance of new xml document
XmlDocument doc = new XmlDocument();

// load from file by path
doc.Load(@"C:\sitemap.xml");

// load from stream
doc.Load(File.OpenText(@"C:\sitemap.xml"));

// load from url
doc.Load(@"http://www.csharpdeveloping.net/sitemap.xml");

// load from string
doc.LoadXml("<url><loc>http://www.csharpdeveloping.net/</loc></url>");
Send us feedback about this snippet »



Related Snippets: