Solved

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

Posted on 2003-11-10
3
348 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 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

19 Experts available now in Live!

Get 1:1 Help Now