XML File Output

Authentication Error

You must enter something as your username.

I am currently outputting the following first line in an xml string that I am creating using the documentToXMLString service in webMethods 6.0:

I would like to have the encoding data displayed as well just like the example below:

How can I format this line using webMethods 6.0 without using a replace function.

Sorry here is what the samples should look like:


text = xml version=“1.0”


text = xml version=“1.0” encoding=“UTF-8”

attrPrefix can be used for this. You can add the value xml version=“1.0” encoding=“UTF-8” to attrPrefix in the recordToDocument step.

Once I add the value you specified, how do I have it merged into my xml string?

you can do a

  1. stringToDocument input will be the xmlstring that you created
  2. Document to Record
  3. recordToDocument - it is in this step that you give the value for attrPrefix - the output of this step is a valid xml document

I am using the 6.0 documentToXMLString Service which has an output of type String called xmldata I set the attrPrefix however it did not add it to the xmldata string it still only displayed xml version 1.0

Any ideas

Add a String with the value of @encoding with the value that you want.

There’s an example of how to include the version in the Built-in services users guide in the XML Folder section.

Any field with the attrPrefix (which defaults to ‘@’) that exists in the top level Record that is passed to documentToXMLString will be added to the XML prolog.

You can use a Flow Map Set operation to add this field.

The documentToXMLString hasthe following Service IN parameters:

attrPrefix - String
document - Document
nsDecls - Document
addHeader - String
encode - String
documentTypeName - String
generateRequiredTags - String
enforceLegalXML - String
dtdHeader - Document
bufferSize - String

My input is a recordlist of data, are you saying I should add a field to the top level of this recordlist as @encoding and set the value to xml version 1.0 encode utf-8? And this will populate my record with the proper header?

Add the value ‘’ (please take out the apostrophies) to the attrPrefix variable.

You’ll want to map in a String field into the document input. So using the example from the built-in services guide, the ‘document’ input will have the following structure:

@version 1.0
@encoding UTF-8
AcctInfo whatever data you have

The attrPrefix input defaults to @, but you can change it to something else. For example setting attrPrefix to __Attr, the encoding key would need to be changed to __Attrencoding to get it inserted as an attribute. The resulting XML string would be:

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

Add the value '<?xml version=“1.0” encoding=“UTF-8”?> ’ (please take out the apostrophies) to the attrPrefix variable.

Note that attrPrefix is used in a startsWith test on each key in the IData to see if the entry should be an element or an attribute. Changing this means that you have also set the corresponding attrPrefix in documentToRecord or generated you own IData data using a different naming convention.