cancel
Showing results for 
Search instead for 
Did you mean: 

Injecting new field to xml document

shaji_chandran
Participant
0 Kudos

Hi All,

      I have got an xml document as below structure

    <?xml version="1.0" encoding="UTF-8"?>

    <root>

        <test2></test2>

        <test3></test3>

        <test4></test4>

    </root>

I would like to inject one node as <test1> just before the node <test2>

How can I do this in MII using an assingment operator. Is there any other action block in MII do achieve this requirment?

I am using xMII version 12.1

Please let me know if you have any idea about this.

Thank in advance

Shaji

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Shaji,
Your requirement is not fully clear to me, because what the sample you put here there can be multiple scenario to solve this issue.
I am trying to explain few of them hopefully it will be helpful to you to solve this.

Possibility 1 :

If you have only one parent node and exactly same child node you provided in the sample (I mean to say if the no of child node would be constant), then you can follow this way.

1st prepare a sample XML structure with the new child node in local properties like

<?xml version="1.0" encoding="UTF-8"?>

    <root>

        <test1></test1>

        <test2></test2>

        <test3></test3>

        <test4></test4>

    </root>

then map all the value to that xml in the local variable. so that will be your desire XML. You can do this with Assignment Action block.

Possibility 2:

There will be one parent node but multiple child node (No of child nde may be varied)

Then you have to create a XML structure in the local variable only with the parent node like

<?xml version="1.0" encoding="UTF-8"?>

    <root/>

Then you can use Append XML option in assignment block to add new node under your root node.

possibility 3:

If the MII XML format is allowed for your requirement.

MII XML format is

<?xml version="1.0" encoding="UTF-8"?>

    <Rowsets/>

          <Rowset/>

               <Row/>

If it is allowed to use, then
1st use the action SAP MII XML Output

then 1st use a document action. Under it's configuration, add all the child node.

then in below sequsce add row action block and assign all the values of the child node.

so you will then get the following output

<?xml version="1.0" encoding="UTF-8"?>

    <Rowsets>

          <Rowset>

               <Row>

                   <test1></test1>

                   <test2></test2>

                   <test3></test3>

                   <test4></test4>

               </Row>

          </Rowset>

     </Rowsets>

Hope it will help.

Regards,

Suman

Former Member
0 Kudos

Hi shaji,

you can use Append XML option under assignment to add new node under your root node.

I would like to inject one node as <test1> just before the node <test2>

in XML you can add <test1> after <test4>, it will work same as <test1> before <test2>.

Hope it helps!!

Thanks & Regards,

Manoj Bilthare