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
Solved

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

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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Suggested Solutions

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…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

829 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