Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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;


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>

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
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
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


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.