Question about writexml()
Messages   Related Types
This message was discovered on microsoft.public.dotnet.general.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

MichaelH (VIP)
I have some code that I am modifying. I have a dataset and I am trying to
write the XML declaration . Here is what I am doing:

System.Xml.XmlTextWriter writer = new
System.Xml.XmlTextWrite(dlg.FileName,Encoding.UTF8);
writer.Formatting = Formatting.Indented;
//writer.WriteRaw("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
writer.WriteStartDocument();
objPtMasterListDataSet.WriteXml(writer);
writer.WriteEndDocument();

The problem is I only get part of the XML declaration. Here is what I get:

="1.0" encoding="utf-8"?>

The next tag that is in my file is the name of the table, which I can't seem
to get it to not print. Can anyone possible tell me what is wrong?

Thanks

Reply to this message...
 
    
MichaelH (VIP)
Here is an example of my xml file that gets created:

="1.0" encoding="utf-8"?>
<MyListDS>
<HEADER>
<VERSION>1</VERSION>
<TYPE>MASTER_LIST</TYPE>
<APPID />
<COMMENT />
<DESCRIPTION />
</HEADER>
<DATA>
</DATA>

For some reason the xml declaration has been cut off and should be
<?xml version="1.0" encoding="utf-8" ?>

Also the tag below the declaration is the name of the dataset. Does anyone
know if there is a problem with the WriteStartDocument()? How do you keep
the dataset name from being put in the output?

"MichaelH" wrote:

[Original message clipped]

Reply to this message...
 
    
Cor Ligthert
Michael,

Doing only

ds.WriteXML(pathnameString);

Is enough to write a dataset.
(And when you want the schema as well in it, use than)

ds.WriteXML(pathnameString,XmlWriteMode.WriteSchema);

I hope this helps?

Cor

Reply to this message...
 
    
MichaelH (VIP)
Thanks for the reply. I tried what you said, but I to not need the schema
included in the XML file.

I screwed up my subject. My question is about the WriteStartDocument
function. The XML declaration is being truncated for some reason and the
Dataset name is being dumped out as a tag also. I do not want the table name
to be included.

At a loss as to why the output is messed up.

"Cor Ligthert" wrote:

[Original message clipped]

Reply to this message...
 
 
System.Data.XmlWriteMode
System.Text.Encoding
System.Xml.Formatting
System.Xml.XmlTextWriter




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com