Solved

Quick question...how to print an XMLNodeList to a new XML file?

Posted on 2003-11-10
3
350 Views
Last Modified: 2008-02-26
Okay, this should be an easy one, I hope.

I've read in an xml file with VS .NET in VB as an XML Node list, and modified some of the values, and now all I need to do is print out to a new file.

How do I print out the modified list as an XML file again, keeping the structure intact?

If anyone has any examples or suggestions, it would be much appreciated.

Thanks!
0
Comment
Question by:Inward_Spiral
  • 2
3 Comments
 
LVL 3

Expert Comment

by:sony1464
ID: 9718500
are u trying to save the modified xml as a different name?
0
 
LVL 3

Accepted Solution

by:
sony1464 earned 40 total points
ID: 9718590
I donno if this is what u r looking for.....I jus wrote an example where it reads the xml file  as xmlnodelist, modifies it and saves the whole structure as a different name.

 XMLcardprint.xml
---------------------
<?xml version="1.0" encoding="utf-8"?>
<options>
    <datasetters>
       <datasetter value="EHU" />
      <datasetter value="EHU" />
  </datasetters>
</options>

  Dim m_xmld As XmlDocument= New XmlDocument()
        Dim m_nodelist As XmlNodeList
        Dim m_node As XmlNode
        m_xmld.Load("..\XMLcardprint.xml")
        Dim newnode As Xml.XmlNode
        Dim currentElement As Xml.XmlElement
        Dim currentElement1 As Xml.XmlElement
        Dim datasetterelement As Xml.XmlNodeList
        currentElement1 = m_xmld.SelectSingleNode("/options/datasetters")
        datasetterelement = currentElement1.SelectNodes("datasetter")
        For Each newnode In datasetterelement
            currentElement = CType(newnode, Xml.XmlElement)
            Dim s As String = currentElement.GetAttribute("value")
            If s = "EH" Then
                currentElement.SetAttribute("value", "EHU")
            End If
        Next
        m_xmld.Save("..\XMLcardprint1.xml")

0
 

Author Comment

by:Inward_Spiral
ID: 9724452
That'll do, sony. Thanks!
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now