Is there some javaScript implementation to handle deltas between XML data?
The main point is to detect the existence of the difference, it doesn't matter what was changed: attribute or node value.
Requirements are as follows:
- Each node will have unique id (it's one of the simplifications made to find more candidates-libraries)
- Deltas should be checked in nodes, attributes and node values
- Support XML node hierarchies up to 3 levels
- The result of computation should be also XML (see example), but it could be 3 arrays of added, updated and deleted nodes
- Ignore some subnodes in delta calculation, for example I want to track just 3 levels of hierarchy, not more
- Changes detection should not be propagated to upper nodes, so for example child node changes should not make parent node updated
Here is example how it should work:
XML#1:
<node id="0">
<node id="1">
<node id="4">
<node id="23">DATA</data>
</node>
<node id="5">DATA</node>
</node>
</node>
XML#2:
<node id="0">
<node id="1">
<node id="3">
<node id="342">DATA</data>
</node>
<node id="5" some_attribute="attr"/>
</node>
<node id="6"/>
</node >
So result should be the following:
<result>
<added>
<id>6</id>
<id>3</id>
<id>342</id>
</added>
<updated>
<id>5</id>
</updated>
<removed>
<id>4</id>
<id>23</id>
</removed>
</result>