DOMElement in Delphi

后端 未结 2 620
野性不改
野性不改 2021-01-29 01:35

how i can use .getElementsByTagName in DOMNodeList Object ? Like:

procedure TForm1.selecionarClick(Sender: TObject);
var  DOMDocument: iXMLDOMDocument;
     DOM         


        
2条回答
  •  [愿得一人]
    2021-01-29 01:44

    IDOMElement supports getElementsByTagName which returns an IDOMNodeList. IDOMElement is a "subclass" of IDOMNode.

    var
     DOMNode: IDOMNode;
     DOMElement: IDOMElement;
    begin
      if Node.DOMNode.nodeType <> ELEMENT_NODE then
        exit;
    
      // Obtain IDOMElement interface
      DOMElement := (DOMNode as IDOMElement);
      // Fetch node list
      DOMNodeList := DOMElement.getElementsByTagName('search text');
    
      // Do whatever with the list....
    end;
    

    Hope that helps. :)

提交回复
热议问题