Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: XML XAML VB.NET .NET4.5
i want to write some data in XML file using metro style app (.Net Framework 4.5).
 
here is the code which i have written and it works fine but problem is that the whole string is being written in s single line instead of XML text formatting. Therefore i can't read it properly. Every time i need to reformat the newly added data to understand it properly.
 
Here is the code i have written :
 
        Dim f As New FolderPicker
        f.SuggestedStartLocation = PickerLocationId.DocumentsLibrary
        f.ViewMode = PickerViewMode.Thumbnail
        f.FileTypeFilter.Add("*")
        Dim folder As StorageFolder = Await f.PickSingleFolderAsync
 
        Dim rootEle As XmlElement
 
        Dim file As StorageFile = Nothing
 
        file = Await folder.CreateFileAsync("demoXML.xml", CreationCollisionOption.ReplaceExisting)
 
        rootEle = doc.CreateElement("files_tbl")
        doc.AppendChild(rootEle)
 
        Dim ele As XmlElement
        ele = doc.CreateElement("files")
        rootEle.AppendChild(ele)
 
        Dim otherEle As XmlElement
        otherEle = doc.CreateElement("field-1")
        otherEle.InnerText = "data-1"
        ele.AppendChild(otherEle)
 
        otherEle = doc.CreateElement("field-2")
        otherEle.InnerText = "data-2"
        ele.AppendChild(otherEle)
 
        Await doc.SaveToFileAsync(file)
Posted 26-Feb-13 2:53am
Comments
Jeff Blankenburg at 26-Feb-13 9:22am
   
What tool are you using to view your XML? I don't recommend bloating your file with newline characters if you can avoid it. Notepad++ does a great job at auto-formatting XML, as does the XML viewer in Visual Studio.
Vivek-The Geek at 26-Feb-13 11:00am
   
I'm using Notepad++. But still it shows all the contents in single line..
To format it, i need to format it manually by adding tabs.
 
Is there any bug in the code above ???

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 315
1 OriginalGriff 233
2 Aajmot Sk 224
3 Richard MacCutchan 220
4 Marcin Kozub 210
0 OriginalGriff 7,853
1 Sergey Alexandrovich Kryukov 7,107
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,790


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 26 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100