Einzelnen Beitrag anzeigen

marabu

Registriert seit: 6. Apr 2005
10.109 Beiträge
 
#4

Re: Node von einem Dokument zum anderen kopieren

  Alt 8. Aug 2006, 19:38
Schade, dass du deinen Code nicht zeigen kannst. Ich hatte gefragt, weil ich da kein Problem kenne:

Delphi-Quellcode:
uses
  MSXML2;

procedure TMainForm.ButtonClick(Sender: TObject);
var
  inDoc: IXMLDOMDocument2;
  outDoc: IXMLDOMDocument2;
  nIn, nOut: IXMLDOMNode;
  msg: String;
begin
  inDoc := CoDomDocument.Create;
  inDoc.async := False;
  outDoc := CoDomDocument.Create;
  outDoc.async := False;

  with inDoc do
  begin
    documentElement := CreateElement('inroot');
    nIn := documentElement.appendChild(CreateElement('intest'));
  end;

  with outDoc do
  begin
    documentElement := CreateElement('outroot');
    nOut := documentElement.appendChild(CreateElement('outtest'));
    nOut.appendChild(nIn.cloneNode(False));
    if Assigned(inDoc.documentElement)
      then msg := inDoc.xml
      else msg := 'n/a';
    ShowMessage('after node copy:'#13#10
      + 'inDoc.xml:'#13#10
      + msg + #13#10
      + 'outDoc.xml:'#13#10
      + outDoc.documentElement.xml
    );
  end;

  with outDoc do
  begin
    documentElement := inDoc.documentElement;
    if Assigned(inDoc.documentElement)
      then msg := inDoc.xml
      else msg := 'n/a';
    ShowMessage('after node transfer:'#13#10
      + 'inDoc.xml:'#13#10
      + msg + #13#10
      + 'outDoc.xml:'#13#10
      + outDoc.documentElement.xml
    );
  end;

end;
marabu
  Mit Zitat antworten Zitat