DOMElement in Delphi

青春壹個敷衍的年華 提交于 2019-12-02 09:37:26

GetElementsByTagName is not a member of IXMLDOMNodeList, but of IXMLDOMDocument. On IXMLDOMNodeList, to grab by tag name you must loop using this type of construct:

for i := 0 to DOMNodeList.length - 1 do
begin
  DOMNode := DOMNodeList[i];
  if DOMNode.nodeName = 'aTagName' then
   DoStuff(DOMNode);
  // etc etc....
end;

HTH

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. :)

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