Click here to Skip to main content
15,795,581 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I have this Xml code :

<pre><?xml version="1.0" encoding="UTF-8"?>
        <name>Ceci est une description pour le paramètre 1.</name>
        <name>Ceci est une description pour le paramètre 2.</name>
        <name>Ceci est une description pour le paramètre 3.</name>

And I want to do create a script VBNET in order to add new data with a key, value, unit and name.

What I have tried:

dim parametre as System.Xml.XmlDocument;
parametre = new System.Xml.XmlDocument;

dim catalog as System.Xml.XmlElement;
catalog.SetAttribute("1", "0385503822");

' save the XML document to disk
Updated 14-Apr-23 0:21am

1 solution

How do you expect that to work?
It appends the node to itself as a child node!
Even if it worked, when you tried to write it to a file, it would loop infinitely trying to get to the end of the children ...

Did you mean to add it to the parametre instead?
Share this answer
Richard Deeming 14-Apr-23 5:26am    
It won't even get that far - catalog is never assigned a value, so the catalog.SetAttribute call will throw a NullReferenceException. :)
OriginalGriff 14-Apr-23 6:07am    
That's why "Even if it worked" :D

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900