Video Screencast Help
Search Video Help Close Back
to help
New in the Rewards Catalog: Vouchers for "Symantec Technical Specialist" and "Symantec Certified Specialist" exams.

Append XML data to existing XML document.

Updated: 21 May 2010 | 6 comments
JeffHu's picture
0 0 Votes
Login to vote
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

EdT's picture
09
Feb
2010
0 Votes 0
Login to vote

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.

nac's picture
09
Feb
2010
0 Votes 0
Login to vote

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.

VBScab's picture
10
Feb
2010
0 Votes 0
Login to vote

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.

JeffHu's picture
10
Feb
2010
0 Votes 0
Login to vote

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.

VBScab's picture
10
Feb
2010
0 Votes 0
Login to vote

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.

JeffHu's picture
10
Feb
2010
0 Votes 0
Login to vote

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.