Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Insert node within XML variable?

Avatar

Avatar
Validate 1
Level 3
BjornEricsson1
Level 3

Likes

2 likes

Total Posts

48 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 3
BjornEricsson1
Level 3

Likes

2 likes

Total Posts

48 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile
BjornEricsson1
Level 3

24-04-2017

How do I specify the Location within an XML variable so that the XML selected by the expression will append this data?

I tried /process_data/TestXML/*/*[last()] as Location, but that replaced the selected node, not appended after.

Replies

Avatar

Avatar
Validate 25
Level 5
James_R_Green
Level 5

Likes

47 likes

Total Posts

191 posts

Correct Reply

47 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 5
Boost 3
View profile

Avatar
Validate 25
Level 5
James_R_Green
Level 5

Likes

47 likes

Total Posts

191 posts

Correct Reply

47 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 5
Boost 3
View profile
James_R_Green
Level 5

02-05-2017

Hi,

 
If I have understood your question correctly, you should be able to add a node by referencing it by name (even though it doesn't exist yet) and setting it to a value for example:
 
/process_data/testXML =
 
<test>
<field1>a</field1>
<field2>b</field2>
<field3>c</field3>
</test>
 
If we add "SetValue" activity to our process with the following settings:
 
Location /process_data/testXML/test/field4  Expression "new value"
 
 
testXML would then equal:
 
<test>
<field1>a</field1>
<field2>b</field2>
<field3>c</field3>
        <field4>new value</field4>
</test>

Avatar

Avatar
Validate 1
Level 3
BjornEricsson1
Level 3

Likes

2 likes

Total Posts

48 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 3
BjornEricsson1
Level 3

Likes

2 likes

Total Posts

48 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile
BjornEricsson1
Level 3

02-05-2017

Thanks, but there might already be a node called testXML/test/field4 that I then would replace. I need to  insert a new one without replacing any old ones. Does that explenation make sese?

Avatar

Avatar
Validate 1
Level 3
BjornEricsson1
Level 3

Likes

2 likes

Total Posts

48 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 3
BjornEricsson1
Level 3

Likes

2 likes

Total Posts

48 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile
BjornEricsson1
Level 3

02-05-2017

Thanks, but there might already be a node called testXML/test/field4 that I then would replace. I need to  insert a new one without replacing any old ones. Does that explenation make sese?

Avatar

Avatar
Boost 5
Level 3
lesutton1
Level 3

Likes

9 likes

Total Posts

47 posts

Correct Reply

14 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Applaud 5
Affirm 5
View profile

Avatar
Boost 5
Level 3
lesutton1
Level 3

Likes

9 likes

Total Posts

47 posts

Correct Reply

14 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Applaud 5
Affirm 5
View profile
lesutton1
Level 3

03-05-2017

Bjorn, if you want to insert nodes, then I'd recommend going straight to the script component, or alternatively create your own custom DSC JAR that allows you to insert, and remove nodes. If you do know how many nodes you have in your XML, adding a node via /VariableName/NodeName[1] will create a new node for you. Again, custom DSC will allow you much more flexibility when it comes to manipulating XML.