XML Declaration is missing when I convert a dataset to xml

This is my first time trying to take the results of a query that
reside in a Dataset and convert the dataset into an xml file. 
Everything works great, except that my resulting XML file is missing
the xml declaration (the first line): <?xml version="1.0"
encoding="iso-8859-1"?>

Below is an example of the code I am using:
dataset.Namespace = "RatesXML"
Dim xmlFilename As String = "myXmlDocument.xml"
Dim fsWriteXml As New System.IO.FileStream(xmlFilename,
System.IO.FileMode.Create)
Dim xmlWriter As New
System.Xml.XmlTextWriter(fsWriteXml,System.Text.Encoding.Unicode)
dataset.WriteXml(xmlWriter)
fsWriteXml.Close()
dataset.Dispose()
Dim newDataSet As New DataSet("New DataSet")
Dim fsReadXml As New System.IO.FileStream(xmlFilename,
System.IO.FileMode.Open)
Dim myXmlReader As New System.Xml.XmlTextReader(fsReadXml)
newDataSet.ReadXml(myXmlReader)
myXmlReader.Close()

I get back my xml file with all the children and elements as expected,
except the declaration is not present.  How can I get the xml
declaration to appear in the new xml file?  I assume it is an option
that I can add. Thank you.
0
bacile99 (1)
10/26/2004 2:53:59 PM
dotnet.xml 7266 articles. 0 followers. Follow

1 Replies
698 Views

Similar Articles

[PageSpeed] 10

Todd wrote:

> This is my first time trying to take the results of a query that
> reside in a Dataset and convert the dataset into an xml file. 
> Everything works great, except that my resulting XML file is missing
> the xml declaration (the first line): <?xml version="1.0"
> encoding="iso-8859-1"?>
> 
> Below is an example of the code I am using:
> dataset.Namespace = "RatesXML"
> Dim xmlFilename As String = "myXmlDocument.xml"
> Dim fsWriteXml As New System.IO.FileStream(xmlFilename,
> System.IO.FileMode.Create)
> Dim xmlWriter As New
> System.Xml.XmlTextWriter(fsWriteXml,System.Text.Encoding.Unicode)

So if you want iso encoding, why do you write it as Unicode? Write it in 
ISO-8859-1 encoding.

-- 
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
0
Oleg
10/26/2004 3:13:39 PM
Reply:

Similar Artilces:

XML Header
Hi, I have some XML doc loaded in a C# Web Service. XmlDocument doc = new XmlDocument(); doc.LoadXml(myDoc); Code Missing to manipulate header (I would like to replace or manupulate all these XXXXX): <mso-XXXXXX productversion="XXXXXX"> <mso-application progid="XXXXX"?> doc.Save(myNewDoc); Any idea on how to access and manipulate data within the doc header? Thanks vbdev vb6dev2003 wrote: > I have some XML doc loaded in a C# Web Service. > XmlDocument doc = new XmlDocument(); > doc.LoadXml(myDoc); > > Code Missing to manipulate header ...

Missing transactions again......
*Sigh* My Money 2006 Premium is losing downloaded transactions again. After spending two hours on the phone with MS tech support in December and not finding a solution I had to abandon my money data file with four years of data and set up a new one. Ive spent the last six weeks getting everything right in the new file. Then this morning I open Money and it tells me I have 5 downloaded statements to read. I open the list of accounts with statements, and my checking account has (5) in parenthesis - indicating 5 downloaded transactions from my bank. When I open the register there is only...

Read XHTML into XML
Hi all, I need to read/parse XHTML aspx pages and look for certain tokens and content. How can I use a XmlTextReader for this? If not, any other ideas? Thanks in advance, JA Reyes. Jose Antonio Reyes wrote: > I need to read/parse XHTML aspx pages and look for certain tokens and > content. How can I use a XmlTextReader for this? If not, any other ideas? If the pages are well-formed XHTML then it is possible to use XmlReader (in .NET 2.0/3.0) or XmlTextReader (in .NET 1.x) to parse the XHTML documents. You can also use the other XML APIs .NET provides so using XPathNavigator and/o...

Outlook 2000
I have a friend who has Tools missing from his menu bar. Can anyone help on how to get it back? Barry Restore the menu bars, see "Restore Any Toolbar" http://www.officearticles.com/misc/menu_and_toolbar_tips_for_all_microsoft_office_applications.htm ******************* ~Anne Troy www.OfficeArticles.com "Oldmoondog" <oldmoondog@ntlworld.com> wrote in message news:18HIe.550$jv2.474@newsfe2-gui.ntli.net... > I have a friend who has Tools missing from his menu bar. Can anyone help on > how to get it back? > Barry > > ...

FRX Currency Converter
Is there a way to get FRX to use a specific rate? For example, I need to do a consolidated report in USD (for GP companies that have different functional currencies). The problem I'm having is that I need to compare the current week's totals with the same amouts computed using last weeks exchange rate and the exchange rate for the week before that one. Current @ Last Wks FX @ Last 2 Wks FX I've built the consolidated report in USD but I can't figure out how to get the amounts converted at the previous 2 exchange rates. Am I missing something? Help! Alliso...

How to invoke the xml editor?
I installed vs2005 on a new xp pro machine, and installed everything except C++. When I click on a file with a ".xml" extension it is opened with IE. When I click file/Edit with XML Editor, it opens it with Notepad. If I click File/Open With and select XML Editor, it opens it with IE. So, where is the xml editor? Can it be invoked from withing VS? Where? Bill * billsahiker@yahoo.com wrote in microsoft.public.dotnet.xml: >I installed vs2005 on a new xp pro machine, and installed everything >except C++. When I click on a file with a ".xml" extension it is >opened ...

How to convert/post a Publisher page to Yahoo/Geocities?
I asked this question once before and got an answer but didn't save the link. I'd like to know again how I can take a webpage designed using Publsher and post it using Yahoo/Geocities. Currently using Publisher 2003. ...

show XML schema and values
I have an XML document that looks like the following: <record> <Field1>value1</Field1> <Field2>value2</Field2> <Field3>value3</Field3> </record> What I'm aiming to do is to show the data in a report as in the following example: record: Field1 value1 Field2 value2 Field3 value3 The "Field1-3"-elements can have any name, so I'm trying to get a table that has in one result column the element name, and in the second colum...

Offline synch using XML web-services
This is a bit long-winded. Can somebody read thru these 2 use cases, and tell me if it is feasible ? :- Use Case : Replication before Offline Synch Scenario 1 : Oracle Server , MSDE client 1. User clicks on 'Go Offline'. System creates a MSDE SQL database in laptop (client), gets the schemas of the tables in Oracle, creates corresponding tables in client's MSDE SQL (mapping Oracle datatypes to SQL datatypes). 2. Offline replication program reads in the tables of the server into a typed datasets, converts the typed datasets into XML, and stores the XML in the client. (XML serial...

convert military hours
I have columns of data entered in military time that I need to convert as follows: convert 2330 to 11:30 p.m. Using format, cell, time changes everything to 12:00 a.m. Can you use a helper column? =TIMEVALUE(TEXT(A1,"00\:00")) and format the way you like. Excel stores dates as numbers starting from a base date (usually December 31, 1899 for windows users). So when you put 2330 in a cell, xl saw that as 2,330 days after 12/31/1899 (May 18, 1906). And excel stores time as fractions of a day: 1:00 AM is 1/24. 12 Noon = 12/24 = .5. dmeehling wrote: > > I have columns ...

XML Serialization ... how to truncate <?xml...
While xml serializing object how can I truncate <?xml ...?> this line alone? I need to send the serialized xml data to a web method ... since SOAP already have <?xml tag there was some confusion Any help would be greatly appreciated Thank you Regards Raj Raj wrote: > While xml serializing object how can I truncate <?xml ...?> this line alone? Serialize to an XmlWriter created with XmlWriterSettings where you set OmitXmlDeclaration to true. -- Martin Honnen --- MVP XML http://msmvps.com/blogs/martin_honnen/ ...

Group Schedule & Free/Busy Missing
We use SBS2003 w/ Exchange 2003. All clients use WinXP Pro and OL2003. When I create a group schedule one of our staff has no Free/Busy info available. I have looked at her settings in caledar options and it says publish 2 mnths worth every 15 min to server just like everyone else. But the bottom part of the dialog box is missing the publish and search check box. It only has the Publish at my location box. That's the only thing I can see that is different about this users outlook configuration. None of the other users have either box checked under Internet Free/Busy and I can ...

String to xml document
Hi there, I was hoping someone can help me with a little problem I can't seem to find any answers to. I've got a form wich will be posted. On receiving the post I would like to parse a formvar to a xml document. The contents of this formvar (string) will be a valid xhtml document. Can someone give me a startertip (or more :-)) on how to achieve this? tnx in advance, James van der Veen Sjeems wrote: > I was hoping someone can help me with a little problem I can't seem to find > any answers to. > > I've got a form wich will be posted. On receiving the p...

Beginner of XML
I am a beginner of XML. I want to group some files together with a xml file. (it includes a text file, and an image file and a video file) Can someone show me some guidelines? Please help. ...

Valid xml to read from an xml file?
I'm using vb.net, i get an error at the reader line saying the remote server can't be found. Is the below even valid? dim reader as XmlTextReader reader = new XmlTextReader ("http://www.mysite.com/my.xml") do while (reader.Read()) 'do some action here response.write(reader) loop thanx chumley XmlTextReader uses System.Net.WebRequest under the covers -- see if you can figure out how to create a connection that way. Usually there's some proxy server information missing that you can enable if you use WebRequest directly, and then pass the result of GetResponse()...

sorting and grouping window in report designer is missing
Access 2003 - When I toggle the sorting and grouping window in Report Designer, the toolbar button acts like it's toggling on and off (gets highlighted/loses highlight), but the window isn't appearing anywhere. Any ideas? The box is probably opening off screen. This is not uncommon if you have used different monitors, or tested different resolutions. When you click the button, you will see the Access window lose focus as the (off-screen) Sorting'n'Grouping box gets focus. Then press Alt+Space (to drop its control box), M (for Move), and the arrow keys repeated...

Missing Tables: SQL
I ran hotfix for GP9 but I decided not anymore to continue with it because there were other requirements. Thus, I reinstalled the applicaiton GP9 and restored my backup dynamics & company database. There were tables that were lost when I restored it. I just want to know how to copy the tables to my current database. Most of the tables that were lost were from the Cashbook (i.e. CB900045, CB200001) and other tables such as SY00900, SY02200. I was informed that the lack of these tables will not greatly affect our operations (i hope so, please help) ...

Example eConnect XML documents
MSDN says the following: Installing eConnect schema When you include the schemas component of the eConnect install, the installer places schema files in a schemas folder on your computer. The following schema resources are available: The install places the .xsd schema files in the directory c:\Program Files\Microsoft Great Plains\eConnect9\XML Schema\Incoming XSD Individual Schemas. The files in the directory contain the schema for each eConnect XML document. The install places a file named eConnect.xsd that contains the schema definition for all eConnect XML documents. The install typicall...

Saving DataSet as XML in ADO format using VB.NET
Hi, I am trying to convert a lot of web reports from ASP/VB to ASP.NET/VB.NET. I would like to save my dataset in XML and then use XSLT to transform the XML. The catch is I would like to have the XML in the format that ADO uses versus the default format in which ADO.NET uses. Currently, I am using ADO within .NET, but I am concerned about the performance and it might improve if I used the native data providers for .NET. I am not sure if I am missing something but how do I save the .NET DataSet to XML in the OLD ADO format? Thanks for you help in advance and it is most appreciated. In the ...

Can I use Excel to convert Chinese character into Unicode?
as title. I have a list of Chinese characters. And I need to convert them into unicode for further programming. Does Excel provide this converting function? Thanks! ...

converting publisher 98 to 2002 from a disk
I'm having trouble printing publisher98 documents from a disk on a system that runs xp publisher 2002. The font and pictures are distorted. Can any one help? You will have problems as Publisher 98 was not printer driver interdependent like later versions. The only way to overcome this, is to have the same printer driver installed on the computer that Publisher 98 is installed on. However, in saying that, if the Publisher 98 documents being opened in Publisher 2002 are on a computer running Windows XP with Open Type fonts, it still may not be 100%, but certainly less problems than yo...

missing text 02-12-10
Version: 2004 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel Email Client: pop I can't see the some of the text in some of my incoming mail messages in entourage. Some messages are displayed correctly throughout, but some are not. I see the mail heading, but not all of the message text. This applies to both html messages and to plain text messages. If I hit reply (or reply all) I see all of the message text. <br><br>This problem was posted in December by another user, but no resolution was given. ...

97 converted to 2000 becomes very, very slow
I have a whole bunch of Access97 databases which we are converting to Access2000. Most of the converted simple ones perform okay. Of course, a few will need more attention. In the status space at the bottom of the screen, I see more 'Calculating ...' and 'Running query'. And this really slows down the performance of a few of my databases. The databases, in Access97, ran fine. Is there any way I can find out what is being calculated and what queries are being run? Just opening tables in Access2000 is slower than in Access97. Also running queries with linked table...

XML variable for description on receipt?
Hi, I would like to add a description (actually all of those 3 extended descriptions) to display on the printed receipt under the main description. What is the variable to do that? Entry.Item.Description Entry.Item.ExtendedDescription Entry.Item.SubDescription1 Entry.Item.SubDescription2 Entry.Item.SubDescription3 R. "Zorian" <Zorian@discussions.microsoft.com> wrote in message news:F4425EAC-62B6-46FE-826A-D8BA2AA75DBB@microsoft.com... > Hi, I would like to add a description (actually all of those 3 extended > descriptions) to display on the printed receipt un...

Missing text in email
I recently installed Exchange 2003. From time to time when my users send email outside the company there messages are missing text upon arrival. The text missing could be two sentences at the end of a paragraph and the next one starts okay, or it could be a very words missing here and that. Any ideas of this Michelle P. Michelle: I know you have probably thought about this already, but do you have any type of content inspection system installed on your Exchange server? Or anything installed that stamps a message disclaimer on the message. Is the message changed by the clien...