polymod
polymod copied to clipboard
XPath support for merging
trafficstars
XPath is a syntax which allows for robust and deep querying of XML nodes.
XPath has a cheat sheet and an official Haxe implementation.
For the example XML below:
<?xml version="1.0" encoding="utf-8" ?>
<data>
<!--lots of complicated stuff-->
<mode id="difficulty" values="easy"/>
<!--even more complicated stuff-->
</data>
A syntax similar to below would be very useful and much more powerful than the existing format:
<?xml version="1.0" encoding="utf-8" ?>
<merge>
<merge path="//data//mode[@id=\"difficulty\"]" key="values" payload="super_hard"/>
</data>
One useful example is matching multiple nodes. If multiple nodes match the provided path above, all of them could be modified to match the expected value.
You could also add syntax like below, which would delete the node with the type mode within the node data which has the key difficulty, then add the child node <coolbeans foo="bar" /> as a child to the node data.
<?xml version="1.0" encoding="utf-8" ?>
<merge>
<delete path="//data//mode[@id=\"difficulty\"]"/>
<add path="//data">
<coolbeans foo="bar" />
</add>
</data>