Quantcast
Channel: Adobe Community: Message List - ColdFusion
Viewing all articles
Browse latest Browse all 21760

Re: How do I modify XML? I know where it is, but cannot figure out how to modify it

$
0
0

Hey p.sim,

 

I've read the documentation on CF's XML Functions, but nothing has come across as a viable solution. I don't think they are capable of doing what I'm looking for while keeping the data as pure XML.  I was mulling over useing a toString() on the XML to convert it to text and then perform search and replaces, but it's just as convoluted a process.

 

I can use xmlSearch() to find the node that matches the ID provided and get back a copy of its XML.  But I cannot derive any information about that XML node within the master XML doc object so as to reference it, or be able to modify nodes before/after/within it.

 

It's part of a custom template engine I'm building.  You have this base XML which defines elements that are generated to create a page's HTML, and then you have this "Merger XML" which is a series of commands that modify the base XML.  That's where I'm at right now.  This merger XML has commands in it like: insertNode, removeNode, etc.

 

So for example, there could be a command like:

 

<insertNode tplID="abc" direction="before">

     <newNode name="this" value="that" />

</insertNode>

 

So when it gets to this command in the Merger XML, it must be able to look through the base XML and say "Where is there a node that has the attribute of tplID and a value of abc?  OK, THERE it is.  Now I want to insert the value of my child node (<newNode>) before this point in the base XML.

 

The problem is I can use xmlSearch and XPath to FIND these locations in the base XML, but I have no idea how to go forwad from there.  How do I get the reference point so I can then proceed to modify the base XML?  All xmlSearch() gets me is a copy of the matching XML of my XPath query, as expected.


Viewing all articles
Browse latest Browse all 21760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>