I have a string variable populated with an XML fragment. When I use the “Edit XML File” and “XML Save Document” actions to persist this fragment out to a file, the fragment becomes encoded. For example, “<” characters become “<”. How can I prevent this?
Sample fragment (desired):
After saving to document (undesired):
<Target Name=“ProjectA” DependsOnTargets=""><MSBuild Projects=“ProjectA.csproj” Targets="$(Targets)" Properties=“Configuration=$(Configuration);Platform=$(Platform)” /></Target>
Thanks again!
In the previous post, my “desired XML” was removed. It should be something like:
Also, I’m using FB v5.0.0.132.
Jeff - looking into this now. Looks like it’s something to do with the Edit XML action.
That did it! Thanks. I have a related issue…
I have an XML template file (MSBuild project) which looks like:
<?xml version="1.0" encoding="utf-8"?>
Release
AnyCPU
I’d like to add 1:many elements named “Target” within Project. Something like:
<?xml version="1.0" encoding="utf-8"?>
Release
AnyCPU
However, when I use “Edit XML File” to add the Target fragments, the action complains about duplicate root nodes (I think it’s loading the fragment into the DOM…?). When I use “Create XML Node”, the action fails if I don’t supply a “New Node” (understandably). Further, if I add a dummy node for “Create XML Node”, I run into the XML/Text escaping issue above.
So, my work-around is to use “Edit XML File” wrapping my “Target” elements in a dummy “RemoveMe” tag and then using “Text Find/Replace” to pull out the “RemoveMe” tags prior to processing the XML. Ideally, there might be a “Add XML Fragment” action which would allow me to add an XML fragment to an existing file, escaped, without needing a parent node. At some point in my travels, I tried “Merge XML”. I’m sorry but I can’t remember why this didn’t provide quite what I needed.
Thanks!
Jeff - the same fix I did for the edit node has now been put into Create XML Node, so hopefully this will solve this problem? It’s in the next build.
here’s the new build:
https://www.finalbuilder.com/downloads/finalbuilder/500/FB500_147.exe
First, thanks for adding this. However, it’s not quite what I need. I don’t have a “Node Name” (the action errors with “New Node Name is empty” if I fail to provide a node name). I only have an XML fragment I need to place within a parent element. Also, the XML seems to be escaping when added (treating it as text instead of XML). I believe the “Edit XML” action received this functionality (“Treat new value as text” option) with build 5.0.0.143. Perhaps I’m simply not using the action properly…?
Template:
After adding nodes:
Here’s what I’m thinking the input should look like (attached). XML node is simplified for clarify. Obviously, this fails because it lacks a node name.
Jeff - firstly you need to select the “Child xml” radio button so that the action treats the text as xml instead of text. Secondly, yes, you’re right that node name is required. I’ve made a small mod to allow no node name to be specified but I’m afraid that this won’t work for you either as the xml will require a single root node. It will be quite a bit of refactoring to allow a “real” xml fragment, so will have to put this on the todo list as it’s not a quick fix. Anyway, will let you know when the next build is ready.