Parse XML String

In this chapter you will learn:

  1. Load XML data from string

Parse XML string

using System;/*from j  av a 2s.com*/
using System.Xml;

class MainClass
{
  static void Main(string[] args)
  {
    XmlDocument doc = new XmlDocument();
    doc.LoadXml("<R> Value </R>");

    XmlNode root = doc.DocumentElement;
    doc.Save(Console.Out);

    root.RemoveAll();

    doc.Save(Console.Out);
  }
}

The code above generates the following result.

Next chapter...

What you will learn in the next chapter:

  1. How to load and parse XML data from a URL
Home » C# Tutorial » XML
Parse XML file
Parse XML String
Parse XML from URL
Element create
Attribute create
Comments create
XProcessingInstruction
XmlReader
Read double value from XML
XmlReader
XmlReaderSettings
XML formatter
XmlSerializer
XmlTextReader
XmlTextWriter
XmlWriter
XmlWriterSettings
Output XML to console