XmlUtilsWriteShallowNode Method |
Namespace: PDTec.IceNet.Sdk.Utils
public static void WriteShallowNode( XmlReader reader, XmlWriter writer )
static void AddElementWithWriteShallowNode() { XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; using (XmlReader reader = XmlReader.Create("movies.xml")) { using (XmlWriter writer = XmlWriter.Create(Console.Out, settings)) { while (reader.Read()) { if (reader.IsStartElement("dvd") && reader.GetAttribute("genre") == "action") { //Write the dvd element XmlUtils.WriteShallowNode(reader, writer); //Now add a new publisher element to the output writer.WriteElementString("publisher", "metal.sword.com", "Samurai Films"); } else { XmlUtils.WriteShallowNode(reader, writer); } } } } }