المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : XMLwriter error



C# Programming
07-28-2009, 09:21 PM
I have a large xml document and I am extracting out individual nodes from it. I don't want any manipulation.

its like
start-large
start-small
.
.
close-small
start-small
.
.
close-small
and so on.

It works fine if I do.
XmlDocument xmlDoc= new XmlDocument();
xmlDoc.Load(xr.ReadSubtree());
xmlDoc.Save("c:\\one.xml");

But for the following the XMl document I get it messed up.
XmlTextWriter xw = new XmlTextWriter("C:\\two.xml", null);
xw.WriteNode(xr.ReadSubtree(), true);

I get errors like "end element missing" or "not properly closed".

What am I doing wrong in case of text writer? xr is the xmltextReader which is reading the large file.

Your help is appreciated.