Append XML data to existing XML document.
Updated: 21 May 2010 | 6 comments
This issue has been solved. See solution.
Hi,
I am trying to figure out if there is a way for me to append new xml entries into an xml document that already exists on a machine. I am using Wise Installer Editor 7. While it allows me to enable Dynamic Content, this still only allows me to overwrite the existing xml document and not append to it.
discussion Filed Under:
Comments
Use a custom action
If you want to retain full control over your XML file then the most reliable way to proceed, in my experience, is to use a custom action to edit the XML file.
Wisescript has some text processing commands which can loop through a text file and insert or append content, so that is one option open to you. Alternatively, you could write a vbscript custom action to edit the XML. There is plenty of script code on the internet if you search for it, to save having to write it from scratch.
If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.
Little Scripting VB or Wise
You would need a small Piece of code using wise script editor or VBS to do the job. Tell details if you want sample.
There are some script samples...
... knocking around which use the MS XML Parser. You'll find using that a lot easier than trying to parse elements, attributes, etc. in native VBScript.
Don't know why 'x' happened? Want to know why 'y' happened? Use ProcMon and it will tell you.
Think about using http://www.google.com before posting.
Here is an example of what
Here is an example of what I would want to do for test.xml,
<?xml version='1.0' encoding='utf-8'?>
<home-users>
<role rolename="ROLE" description="DESC"/>
<user username="USER1" password="PW" fullName="NAME1" roles="ROLE"/>
</home-users>
I do like to get the following:
<?xml version='1.0' encoding='utf-8'?>
<home-users>
<role rolename="ROLE" description="DESC"/>
<user username="USER1" password="PW" fullName="NAME1" roles="ROLE"/>
<user username="USER2" password="PW" fullName="NAME2" roles="ROLE"/>
</home-users>
So essentially I want to add a second entry under user.
Thanks for the help.
Uh huh...
So you want to add an element called 'user' with attributes 'username', 'password', 'fullName' and 'roles'.
As I mentioned, there are easily-locatable scripts using the XML object to do that.
Don't know why 'x' happened? Want to know why 'y' happened? Use ProcMon and it will tell you.
Think about using http://www.google.com before posting.
Thanks for the input all. I
Thanks for the input all. I am totally new to XML, so I was not aware that I could do this in vbscript. That seems like the best path.
Would you like to reply?
Login or Register to post your comment.