Hi,
I'm struggling with an xml fragment processing issue. I'm using a fragment
saved to a file as a backup of an existing portion of my main XML document.
When the user chooses to restore this portion of main XML document, I just want
to overwrite the current in memory <element> with the original held in the
fragment. The problem I get is after the factory parse, doc.setElement, then
save to file of the main XML, there are duplicate tags in the file e.g
<parent>
<element> -- original tags
<element> ----+ restored tags and contents
<contents> |
</element> +
</element>
</parent>
The document then causes validation errors when its reloaded, as its finding
<element> a second time.
I've managed to find the right combination of settings in the XmlOptions to
call element.save(options) and get the following:
<?xml version="1.0" encoding="UTF-8"?>
<element xmlns="<mynamespace>"
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance>
<contents>
<element>
Note : No "xml-fragment" in the output, and I'm using default namespaces and
prefixes to keep the XML clean.
I then try to read it in as
Element restoredElement = Element.Factory.parse(fragmentFile, options)
and overwrite the original using
parent.setElement(restoredElement);
This doesn't seem to have the desired affect, as its replacing element's
contents and not element itself.
Any suggestions would be appreciated.
Regards
Andrew