g_johnson
asked on
linq to XML doc.save is failing, c#
I have a c# program that creates an xml document using linq to xml:
XDocment doc = new XDocument();
there are over 600 lines of logic building this xml file, culminating in:
string fName = this._writepath + "file856" + curDateTime + ".xml";
doc.Save(fName);
at doc.Save I am getting an error: This operation would create an incorrectly strucutred document.
Unfortunately, this error doesn't happen in my development environment, only in the delivery environment (the executable on the client's machine).
Is there anything I can do to get the executable to show me the structure of the xml so that I can see where it's malformed? In other words, since doc.Save fails, is there some way to throw it into a viewer or a NotePad or something else that would allow me to look at it?
XDocment doc = new XDocument();
there are over 600 lines of logic building this xml file, culminating in:
string fName = this._writepath + "file856" + curDateTime + ".xml";
doc.Save(fName);
at doc.Save I am getting an error: This operation would create an incorrectly strucutred document.
Unfortunately, this error doesn't happen in my development environment, only in the delivery environment (the executable on the client's machine).
Is there anything I can do to get the executable to show me the structure of the xml so that I can see where it's malformed? In other words, since doc.Save fails, is there some way to throw it into a viewer or a NotePad or something else that would allow me to look at it?
ASKER
I'm using utf-8. How does that play into this? The .ToString() method returned the same error.
Can you post the code that builds the XML document please?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Correct -- I agree that it's not well-formed. I am looking for a way to display it so that I can spot the error. So far, I have not been able to get any application of .ToString() to do that for me.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://stackoverflow.com/questions/4533609/how-to-get-xml-as-string-from-xdocument
what encoding are you using, be very wary of UT8 or other non standard formats