Skip to main content
May 23, 2007
Question

How to Edit XML file?

  • May 23, 2007
  • 4 replies
  • 646 views
I have an xml file that I've created, but inside is one are with no value that I need to edit and add a value to before submitting to my process.

For example, in the file is a field with no data like this

BSN=""


I need to open the file, find the BSN="" area, and add a number there like BSN="1" or BSN="2" then save the file.

Is this possible, if so what would be the best way to accomplish this with an xml file?
This topic has been closed for replies.

4 replies

June 1, 2007
Nevermind, I figured out how to navigate to that line.
May 31, 2007
WHAT do I use to find and edit an element? I'v enever done this with xml at all, so this is all new to me.
BKBK
Community Expert
Community Expert
May 31, 2007
In this example we change the value of the BSN attribute of a name element from 2 to 5.

June 1, 2007
BKBK, thank you, that's what I'm trying to do, but I'm not sure how to get down to the level my data is at, it's buried a few layers deeper than that.

My BSN is in the attributes of the Indianaform which is three levels down. how do I navigae to that?


Instead of employee in your example, I have

master/forms/Indianaform

and I need to change the BSN attribute in the Indiana form element
BKBK
Community Expert
Community Expert
May 24, 2007
You could do it in a sequence like:

- <cffile action="read"> to read the xml file
- find and edit an element
- <cffile action="write"> to save the xml file


Inspiring
May 23, 2007
> Is this possible, if so what would be the best way to accomplish this with an
> xml file?

Read the CF docs here:
http://livedocs.adobe.com/coldfusion/7/htmldocs/00001505.htm

And the xpath and XSL stuff here:
- www.zvon.org
- www.w3schools.com

--
Adam

(Is there an echo in this forum?)