Hi.
I got some sample codes from Fig 10 of
http://msdn.microsoft.com/msdnmag/is...L/default.aspx
..
If I read an XML file like:
<test>
<good>1</good>
</test>
The output becomes:
<test>
1
</test>
Why WriteNode dropped the "good" tag?
I want to read an XML file and output an XML file.
Please tell me how to use the following codes.(I modified it a little
bit)
Thank you,
-----------------------------------------------------------------
using System;
using System.Xml;
using System.IO;
using System.Xml.Schema;
// ...
XmlTextReader reader = new XmlTextReader(@"c:\test.xml");
XmlTextWriter writer = new XmlTextWriter(Console.Out);
// Configure reader and writer
writer.Formatting = Formatting.Indented;
reader.MoveToContent();
// Write the root
writer.WriteStartElement(reader.LocalName);
// Read and output every other node
int i=0;
while(reader.Read())
{
// if (i % 2)
writer.WriteNode(reader, false);
i++;
}
// Close the root
writer.WriteEndElement();
// Close reader and writer
writer.Close();
reader.Close();