Solved

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

Posted on 2003-11-10
3
358 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Question has a verified solution.

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

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
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…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

739 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