Is there a generic approach to data merge an xml file content (a template) with embedded XPath expression to an XmlDocument?
As an example, (please note this is just a simple example, i am looking for a generic approach)
File:
<root xmlns:dt="urn:schemas-microsoft-com:datatypes">
<session email='' alias=''>
<state>
<action>
<attribute in_var="" out_var="" entity_name="entity" query_name="query1"/>
<attribute dtype="string" in_var="" name="entity_id" value="$/data/row/entity_id$"/>
</action>
</state>
</session>
XmlDocument:
<data>
<row>
<entity_id>1</entity_id>
<entity_name>Entity 1</entity_name>
</row>
<row>
<entity_id>2</entity_id>
<entity_name>Entity 2</entity_name>
</row>
</data>
After Merge:
<root xmlns:dt="urn:schemas-microsoft-com:datatypes">
<session email='' alias=''>
<state>
<action>
<attribute in_var="" out_var="" entity_name="entity" query_name="query1"/>
<attribute dtype="string" in_var="" name="entity_id" value="1"/>
</action>
</state>
</session>
<root xmlns:dt="urn:schemas-microsoft-com:datatypes">
<session email='' alias=''>
<state>
<action>
<attribute in_var="" out_var="" entity_name="entity" query_name="query1"/>
<attribute dtype="string" in_var="" name="entity_id" value="2"/>
</action>
</state>
</session>
I was under the impression that regular expression backreferences can assist in this scenario but I have hit a dead end.