.NETGURU
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




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification