How to copy a sub node structure from one XML file to another XML file (merge two XML files) using Omni XML as DOMVendor

浪尽此生 提交于 2020-08-10 18:56:25

问题


I asked how to copy a sub node structure from one XML file to another XML file (merge the two XML files) in this question:

How to copy a sub node structure from one XML file to another XML file (merge two XML files)?

The useful and detailed answers from Remy Lebeau and Olivier work fine when I do not set the DOMVendor.

However, when I set the DOMVendor to 'Omni XML', I get an EXMLException error when the cloned node is added to the ChildNodes list:

NewChild was created from a different document than the one that created this node.

The exception is raised in unit Xml.Internal.OmniXML in

function OmniTXMLNode.appendChild(const NewChild: OmniIXMLNode): OmniIXMLNode;
var
  Node: OmniIXMLNode;
  SPrefix: string;
  URIIDCh, URIIDPa: TDicId;
begin
  // NewChild should be created from the same document than the one that created this node
  if (Self.OwnerDocument <> nil) and (NewChild.OwnerDocument <> nil) and (NewChild.OwnerDocument <> Self.OwnerDocument) then
    raise EXMLException.CreateParseError(WRONG_DOCUMENT_ERR, MSG_E_WRONG_DOCUMENT, []);

Target platform is 64-bit Windows. I would like to use 'Omni XML' because it seems to be much faster than 'MSXML'.

How to solve this problem?

来源:https://stackoverflow.com/questions/63160830/how-to-copy-a-sub-node-structure-from-one-xml-file-to-another-xml-file-merge-tw

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!