Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

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

share|improve this answer
1  
Thanks. This led me to develop a solution. –  goodsquishy Jul 24 '13 at 8:12
    
glad that I could help –  Malachi Jul 24 '13 at 13:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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