A better FindNode? XML is weak lazarus / 31-LCL ---------------------------------------------------------------------- edgarrod71 · 2018-05-02 09:53 Hi, I tried to make a FindNode that searches deep inside a XMLDocument, it finds recursively but only finds the first text, but it doesn't find if there are more... how can I fix this? I attached the xml file, but for the example, here's part of the code of the XML: Code: XML  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i                                                                                                       ЖАЛОБЫ                                                                            ____                                                                            {[complaints]}                                                                                                                                                                                                                                                                                                                                                            АНАМНЕЗ    Here's my recursive function, I made a helper for TDOMNode_WithChildren: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function TSearchNode.FindNode(const aNodeName: DOMString;    aNodeContent: DOMString; const aNode: TDOMNode): TDOMNode;var S: String;  /// these two variables are for debugging only... so you can skip them    T: String;     function NodeFound(var Node: TDOMNode): boolean;    var vNode: TDOMNode;        bName: boolean;    begin       result := false;       if Node = nil then exit;        bName := Node.CompareName(aNodeName)=0;       if bName then begin         if UTF8CompareStr(Node.TextContent, aNodeContent)=0 then begin           result := true;             exit;           end;       end;        vNode := Node.FirstChild;        if assigned(vNode) then begin         S := vNode.NodeName;           T := vNode.TextContent;       end;        while assigned(vNode) and not result do begin           result := NodeFound(vNode);           S := vNode.NodeName;           T := vNode.TextContent;           if result then begin             Node := vNode;  /// we must take the value out             break;           end;           vNode := vNode.NextSibling;           if assigned(vNode) then begin               S := vNode.NodeName;             T := vNode.TextContent;           end;       end;    end; begin   if assigned(aNode) then begin     S := aNode.NodeName;     T := aNode.TextContent;   end;    if aNode = nil then      result := FFirstChild    else    if aNode.NextSibling = nil then      result := aNode.ParentNode.NextSibling    else      result := aNode.NextSibling;    while assigned(result) do begin        S := result.NodeName;        T := result.TextContent;        if NodeFound(result) then          break;        result := result.NextSibling;        if assigned(result) then begin            S := result.NodeName;            T := result.TextContent;        end;  end;end;