?
Solved

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

Posted on 2003-11-10
3
Medium Priority
?
367 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 160 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

A new era in Cloud training has arrived.

A day that will go down in Cloud history.. But are you ready for it? Will you accept this Cloud challenge?

Question has a verified solution.

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

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…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

770 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