Xml string to document

Hi
while converting XML string to document i need to convert attributes of elements also.
but i am not able to that.
Can someone tell me how to do that.
Sandeep

Sandeep,

First, get the schema for the XML document you’re trying to convert from string format into a webMethods Document.

Use the schema to create a webMethods Document type in your package.

Then use the following to convert the XML document in string form into an instance of the webMethods Document type just created:

pub.xml:xmlStringToXMLNode
pub.xml:xmlNodeToDocument

Map the output document to a docRef of the webMethods Document type created from the schema.

This converts both attributes and child elements just fine.

If you wish to validate the new XML Document against the schema, you can use the intermediate node that is created by pub.xml:xmlStringToXMLNode to call:

pub.schema:validate

  • Pete

Hi,
I have the same situation, but…
After I have Document (pub.xml:xmlNodeToDocument ) I need to get strings from this document.
Could You tell me, please, how I can do it?
I tried LOOP Input array: document <-but he didn’t want to go into LOOP. Maybe I am doing something wrong?
Thank you,

Sandy,
You can also find it as String valiable with its name starting with @<attr_name> and its value assigned to it after nodeToDoc conversion. You can map it to any other field. Something similar to the attached. But be aware that this method can be followed only if the atrr_name is static or in other words you need to do the mapping for all the different attr_names present. For the later case it is better to follow pete’s suggestion.

@vitalycrash,

LOOP can enter only when it finds an array of the element during runtime that is mentioned in the inputArray property. Now the document that you have mentioned as inputArray is the output document of the nodeToDoc service whihc is not an array, it is just a container document. So you need to find out the repeating element in the XML that you need to exrtact and use it as the input array.
xml_attr.png

good post