XML TAG UPDATE

  • Thread starter Thread starter Guest
  • Start date Start date
Here is a simple example which writes to the first row of the first table in
the XML datafile. You should be able to take it from there.


Public Shared Function ChangeXMLData(strXMLDataFile as string, ,strNewData
as string) as boolean
try
Dim dt as Datatable
Dim ds as New DataSet
ds.ReadXml(strXMLFile, XmlReadMode.InferSchema)
Dim dt as Datatable = ds.tables(0)
dt.rows(0)("YourColumnFieldName") = strNewData
ds.WriteXML(strXMLDataFile)
return true
catch

return false
end try
end function
 
1. Open the document with the XmlDocument class.

XmlDocument MyDoc = new XmlDocument();
MyDoc.Load("C:\MyDoc.xml");

2. Grab the node into an XmlNode object.

XmlNode MyNode = MyDoc.SelectSingleNode("//mynodes[@id='1']");

3. Edit the text using MyNode.InnerText = "my new text".

MyNode.InnerText = "Some new text here";

4. Save the Xml Document.

XmlDocument.Save("C:\MyDoc.xml");


The example above hasn't been tested, and might need some small tweaking,
but should give you a general idea of what you need to do.

Hope this helps,

Mun
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top