Forum guidelines
Writing/Reading XML
Posted By Chris on 24 Apr 2008

Hi, I’m trying to develop a VB.NET application (Original application Developed in PHP) to create XML data that will be used within a PHP application.


I’ve been able to use, but it has not been able to do what I need


textWriter.WriteStartElement("selftestQuestion") 'START Question Element



I need it to produce a Element Tag that look like below, but I can’t seem to use WriteStartElement to do this. 


<selftestQuestion sourceID="1">




Is there any other VB.Net function that can be used to write XML that allows me to insert more data into the Element Start tag



Re: Writing/Reading XML
Posted By Bechir Bejaoui on 24 Apr 2008  
you can use the System.Xml.XmlTextWriter to write into an xml file and use the XmlTextReader to read from an xml file too here is an example of how to use the XmlTextWriter

Dim Writer As System.Xml.XmlTextWriter = New System.Xml.XmlTextWriter("C:\File.xml", New System.Text.UTF8Encoding())
        Writer.WriteStartElement("x", "root", "urn:1")
        Writer.WriteStartElement("x", "item", "urn:1")
you can use simply the XmlDocument as follow

Dim doc As System.Xml.XmlDocument = New Xml.XmlDocument()
        doc.LoadXml(("<book><A property='a'><B>text</B><C>textg</C><D>99999</D></A></book>")
use Load method to charge a given xml file into the xml document if you want to obtain a given xml file content

Every one among us was a beginner once.
C# Corner Annual Conference 2016


Custom Software Development
MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.