4

I need to write a map of string data to an XML document. The XML document has a specific format. An entry key determines where in the XML document the value will be written to. See below for an example (pseudo-code where appropriate);

map = {"document_id": "123"; "document_type": "type_A"}

Produces an XML file like this;

<document>
    <document_id>123</document_id>
    <document_type>type_A</document_type>
</document>

I need the format of the target XML document (and where the map data is written to in it) to be user-configurable. For example;

<node name="document">
    <node name="document_id">${document_id}</node>
    <node name="document_type">${document_type}</node>
</node>

I feel like my proposed solution would be complex and a re-invention of the wheel. I figure there must be some established way to do this but after searching the internet I can't seem to find it. Can anyone offer suggestions on how I may achieve what I want to do?

5

have you looked into using an XSLT file for transforming the information?

I imagine that you could take the Data entered into a form and create a new XML file and then use an XSLT file to format it to the right XML format and insert it into your target XML.

I think this is kind of what you are looking for if i read the question correctly

|improve this answer|||||
  • glad that I could help – Malachi Jul 24 '13 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.