XML parsing in webMethods

Greetings Community,

I ran into a problem parsing XML file which isn’t giving me the results I expect.

high level steps of flow service are as following:

  1. read file using

  2. convert xml string to XmlNode

  3. Get iterator against XmlNode (where its criteria is assigned value “Customer”)

  4. invoke getNextXmlNode inside REPEAT flow step
    following is the output of this step in debug view:

  5. Invoke xmlNodeToDocument
    following is the output of this step in debug view:

  6. Invoke documentToXMLString
    following is the output of this step in debug view:

  7. Create new string in a MAP flow set as following:
    “<Customer>” + value of xmldata + “</Customer>”

  8. write value of newly created string (in above step) to a file on local disk using:

Now actual content (xml) written to file (in above step) is as following:

Now problem is that the xml data written to local disk file is not reflecting attribute “CustomerID” correctly in xml as highlighted in below screenshot:

I wanted to seek help from respected community members in this regard. Can some one please guide me how I can have the CustomerID attribute written correctly in output file instead of the way it is currently being written (highlighted in yellow color in above screenshot)


For your reference following is the actual source xml data sample:

Can you share the source file with data minimized?

Create a documentType for your customer info and use that documenTypeName. use that documentTypeName in XML BIS



You can write the xmldata string to file.

Input and output look like below for me

you mean this?

No need for the source file. I created my own source data and tested it. I posted the solution here. Can you take a look at my previous comment

Thanks @Mohankumar_N !!
but if I change my criteria in the Iterator, then should have to create another DocumentType for another entity.
means I have to put everytime… like its a solution for one entity only

I assumed the criteria is static.I tried the dynamic approach. Let’s see if this works for you

You have to place the fields inside a wrapper document so documentToXMLString assigns the attribute properly.

if you cannot use documentTypeName then we have to go for the java service to create a wrapper document


Jave service to create a wrapper.

Java service

// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();		
// document
IData document = IDataUtil.getIData( pipelineCursor, "document" );
String name = IDataUtil.getString( pipelineCursor, "name" );

IData output = IDataFactory.create();
IDataCursor outputCursor = output.getCursor();
IDataUtil.put(outputCursor, name, document );
// pipeline
IDataCursor pipelineCursor_1 = pipeline.getCursor();		
IDataUtil.put( pipelineCursor_1, "output", output );

output has a wrapper document with the name of the name passed as input

I got you !!!
but it only creates a named document according to the (given) criteria, what about the different variable/names of the entity that lie under the document?
for your understanding, two different nodes :

All the child elements inside the Customer document or Order document will be taken. Have you tried this solution on your server with your source file?

Criteria is Customer. Input and result :

Criteria is Order. Input and result :

Yes, Thanks for helping !

1 Like