"chris ong via DotNetMonster.com" <fo***@nospam.DotNetMonster.com> wrote in message
news:b9******************************@DotNetMonste r.com...
i wish to ask if anyone can help mi to convert a XML file to a normal text
file that does not contain the tags and header.. i just want the
information of the columns ..
You can Load( ) your text file into an XmlDocument, and then just take its
InnerText property. That strips out all of the tags, and the XML declaration.
If there are some tags that comprise this header of which you speak, then
you'd need to locate it in the XmlDocument and call RemoveChild( ) first.
For example, given this XML file,
- - - wannabeText.xml
<?xml version="1.0"?>
<doc>
<group>
<column>sold</column>
<column>36 acres real estate zoned office/industrial</column>
</group>
<group>
<column>sold</column>
<column>case of soft drinks</column>
</group>
</doc>
- - -
and this handful of C#,
XmlDocument doc = new XmlDocument( );
doc.Load( "wannabeText.xml");
Console.WriteLine( doc.InnerText);
produces this text-only output,
sold36 acres real estate zoned office/industrialsoldcase of soft drinks
which is just the concatenated text of each tag having text, in the order they are
encountered within the document. Any semblence of formatting or structure is
of course lost with the tags. If you want text in some kind of structure then its
a little more work to walk through the XmlDocument (FirstChild, NextSibling,
NodeType, Value) to get the fields you want when you want them and place
them into the text output in the structure you want.
Derek Harmon