Re: [fpc-pascal] TDomNode to text and/or document

2014-09-22 Thread Vojtěch Čihák

Hi,
 
this is working code:
 
...
if not assigned(XMLDoc) then XMLDoc:=TXMLDocument.Create;
  with XMLDoc do
    begin
      if not assigned(DocumentElement) then
        begin
          aNode:=CreateElement(cRoot);
          AppendChild(aNode); 
        end;  
      if ASchemeNode='' then ASchemeNode:=cScheme;
      aNode:=DocumentElement.FindNode(ASchemeNode); 
      if not assigned(aNode) then
        begin
          aNode:=CreateElement(ASchemeNode);
          DocumentElement.AppendChild(aNode);
        end;  
   ...
end;  
 
so simply you have to create DocumentElement (i.e. root node) and append 
children there.
 
Vojtěch 
__

Od: Felipe Monteiro de Carvalho felipemonteiro.carva...@gmail.com
Komu: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org
Datum: 22.09.2014 12:38
Předmět: [fpc-pascal] TDomNode to text and/or document


Hello,

I have a TDomNode (laz2_dom, but I guess it should be the same for all
implementations).

Is it possible to get a TXMLDocument from it? I tried:

 lDoc := TXMLDocument.Create;
 try
   lDoc.AppendChild(ANode);

but it crashes =(

Is it possible to get the full text of this node? something like:

svg bla blasub itemetc etc etc/subitem/svg

TextContent doesn't help at all here.

thanks,
--
Felipe Monteiro de Carvalho
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] TDomNode to text and/or document

2014-09-22 Thread Daniel Gaspary
On Mon, Sep 22, 2014 at 8:21 AM, Felipe Monteiro de Carvalho
felipemonteiro.carva...@gmail.com wrote:
 Ummm, this doesn't seam to help much... but I eventually found googling.

 The error is EDOMWrongDocument, which makes sense since I want to
 insert a TDOMNode from another document ... so I have to first import
 and then attach the node:

   lDoc := TXMLDocument.Create;
   try
 lImportedNode := lDoc.ImportNode(ANode, True);
 lDoc.AppendChild(lImportedNode);

I didn't knew this method, but looking the code I understand why. Is
because it is almost an alias to CloneNode, the method I use.


 By the way, whats the difference between TDOMNode and TDOMElement? 
 Confusing...

TDomNode is the base class, can be an attribute, a Processing
Instruction, a Text node...

TDomElement is one of its descendents.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal