Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XmlDocument save problem

Status
Not open for further replies.

fostom

Programmer
Jul 3, 2002
31
NO
Hi!

I am loading an existing xml file and then save like this:
Dim xmldoc1 As XmlDocument
xmldoc1 = New XmlDocument
xmldoc1.Load(thaFile)
xmldoc1.Save(thaFile)

But when the xml file is saved some of the root element is missing, like this:

before: <?xml version="1.0"?>
after: xml version="1.0"?>

..as you see the '<?' is deleted at the start of the element. I am goin' nuts!!

Please help!!!

Tommy
 
Can you provide the contents of the XML file as I have tried a simple example and I am unable to replicate your problem (I don't see any difference in my file).

If you still have problems later you could try reading the
xml file in as a string and writing it out using the text writer but save it with an xml extension.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
thx for quick reply.. the xml code is:

<?xml version="1.0"?>
<?NuDoc tsl_version="7"?>
<PF_Designer_Doc use_legacy_font_ascenders="7" line_spacing_accomodates_default_font="false" interparagraph_space_overlaps="false" pfdoc_left_right="false" use_baseline_for_fixed_line_spacing="true" composition_version="7">
<Doc_Page_Base guides_horizontal="" guides_vertical="" grid_columns="100.000000scale" grid_rows="height=shrinkwrap" bottom_margin="0" right_margin="0" top_margin="0" left_margin="1.000000pt" height="shrinkwrap" width="1420000">
</Doc_Page_Base>
</PF_Designer_Doc>
<!-- Pageflex Creation Data
Created by: Pageflex Designer
AppVersion 3.5.1.147
EngineVersion 4.0.7.5
-->
 
That's very strange as it seems to work fine for me. Just to clarify this is my code:

Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim xmldoc1 As System.Xml.XmlDocument
xmldoc1 = New System.Xml.XmlDocument
xmldoc1.Load("C:\Inetpub\[URL unfurl="true"]wwwroot\TestSite\XMLTest.xml")[/URL]
xmldoc1.Save("C:\Inetpub\[URL unfurl="true"]wwwroot\TestSite\XMLTest.xml")[/URL]

End Sub

and my XMLTest.xml file looks like:

Code:
<?xml version="1.0"?>
<?NuDoc tsl_version="7"?>
<PF_Designer_Doc use_legacy_font_ascenders="7" line_spacing_accomodates_default_font="false" interparagraph_space_overlaps="false" pfdoc_left_right="false" use_baseline_for_fixed_line_spacing="true" composition_version="7">
  <Doc_Page_Base guides_horizontal="" guides_vertical="" grid_columns="100.000000scale" grid_rows="height=shrinkwrap" bottom_margin="0" right_margin="0" top_margin="0" left_margin="1.000000pt" height="shrinkwrap" width="1420000">
  </Doc_Page_Base>
</PF_Designer_Doc>
<!-- Pageflex Creation Data
Created by: Pageflex Designer
AppVersion 3.5.1.147
EngineVersion 4.0.7.5
-->

The xml code is exactly the same after running the page load...

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Thank you for setting me on the right track! Seems to be a bug of some sort. I created a new aspx page with a fresh xml file, then it suddenly worked as it shold. I can't explain why.. maybe my laptop needs a restart or something.. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top