Adding a node through XPath

Avatar

Avatar

yodadobe

Avatar

yodadobe

yodadobe

02-03-2009

I need to add an item into my XML.


user1


to


user1
user2


I thought I read where I could just set a value to the new index: Approvers/Approver[2]/ApproverID="user2"

That is not working though.

Replies

Highlighted

Avatar

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692
pguerett

03-03-2009

Nope the Approver[2] node must exist for that to happen. You can replace nodes that exist so if you changed the Approvers node with the new XML then you would get your desired result.
Highlighted

Avatar

Avatar

yodadobe

Avatar

yodadobe

yodadobe

03-03-2009

I need the old data plus the new so I end up with the same problem creating the new XML. My work around is to do it with Strings then replace, but it is messy.
Highlighted

Avatar

Avatar

neptas

Avatar

neptas

neptas

04-03-2009

Hi,

I need something similar: I have a document var with a xml document. I need to take part of that xml (a specific nodeset) and add it to a string.



any ideas to acomplish this?



thank you
Highlighted

Avatar

Avatar

Jasmin_Charbonn

Avatar

Jasmin_Charbonn

Jasmin_Charbonn

04-03-2009

First you want to put the content of the document into a XML var so you can use xPath.



You can use xPath to get to the node you want (ex. /process_data/myXMLVar/Root/Customers).



Then use the serialize function from the xPath editor (under Misc) to convert the nodes into a string:



serialize(/process_data/myXMLVar/Root/Customers)



Finally you can use the concat function from the xPath editor (under string) to merge two strings together:



concat(/process_data/@myStringVar, serialize(/process_data/myXMLVar/Root/Customers))



Jasmin
Highlighted

Avatar

Avatar

The_Flex_Viking

Avatar

The_Flex_Viking

The_Flex_Viking

05-03-2009

Write an ExecuteScript activity?
Highlighted

Avatar

Avatar

Jasmin_Charbonn

Avatar

Jasmin_Charbonn

Jasmin_Charbonn

05-03-2009

I don't understand your question.



Jasmin
Highlighted

Avatar

Avatar

Steve_L_Walker

Total Posts

1.4K

Likes

197

Correct Answer

212

Avatar

Steve_L_Walker

Total Posts

1.4K

Likes

197

Correct Answer

212
Steve_L_Walker

07-03-2009

A node can be added to an XML instance using XSL in an XSLT Transform service, also.

My sample process uses two input process variables:

1. 'inputXml' of type xml


user1


2. 'approverId' of type string

foobar

I define the following XSLT template which consumes the input process variable 'approverId':



ApproverID
{$ /process_data/@approverId $}









The result of the applying the XSL is as follows:



user1


foobar



The process could be designed to iterate over the input XML and the XSL.

Steve