• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to Edit XML file?

Explorer ,
May 23, 2007 May 23, 2007

Copy link to clipboard

Copied

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?
TOPICS
Advanced techniques

Views

511

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 23, 2007 May 23, 2007

Copy link to clipboard

Copied

> 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?)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 24, 2007 May 24, 2007

Copy link to clipboard

Copied

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


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 31, 2007 May 31, 2007

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 31, 2007 May 31, 2007

Copy link to clipboard

Copied

In this example we change the value of the BSN attribute of a name element from 2 to 5.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 01, 2007 Jun 01, 2007

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 01, 2007 Jun 01, 2007

Copy link to clipboard

Copied

LATEST
Nevermind, I figured out how to navigate to that line.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation