Navigation:  Advanced Topics >

Reading a CR/LF filled XML file into one metadata record

When I first found myself playing around with XML I wanted to do a lot of testing. I got some XML ready for making SOAP calls as it happens and I then wanted to read this in from a file and pass it to the HTTPConnector component (later section in this QSG) to make the SOAP call.

 

Whatever the type of XML, if you want to read it from a file and pass it to the output port metadata, you will have one major problem - the metadata setup will split each line of the XML up into sepearate rows and then pass these rows to the HTTPConnector one by one. Not good.

 

So, what you do is easy but a bit fiddly. You have to make some Metadata settings and do this in rather a fiddly way.

 

Create a standard XML Metadata definition

Why not create a permanent "MyXML" metadata type if you use XML a lot. You can then use this for any Graph of project and it will work for managing your XML string.

 

 

Spanner

1.Create a new "User Defined" Metadata record (I called mine "XMLData")
2.Change field 1 to "XMLString" or similar
3.Click on the XMLData "Record;" row
4.On the right hand side, remove both the Record delimiter and the Default delimiter. This overrides the individual field settings at this point. Make sure you delete the entire contents of the fields and there are no spaces left lurking.
5.Select the XMLString field.
6.On the right hand side, scroll down to the very bottom and set the "EOF as delimiter" to true.

 

MetadataXMLDef

 

7.Press "Tab" to exit the field and any red errors there might have been should disappear.
8.Press Finish.
9.To test this, go back and edit the metadata. At the bottom you will now see a "Browse..." button which enables you to load a file into the metadata. Try this out.  You should see at the bottom your multi-line XML file and above it a long single line of XML.

 

MetadataXMLString