Hello,
as far as I tested TDOMNodeList.GetItem is not working correctly.
--------- original ---------------
function TDOMNodeList.GetItem(index: LongWord): TDOMNode;
var
  child: TDOMNode;
begin
  Result := nil;
  child := node.FirstChild;
  while Assigned(child) do
  begin
    if index = 0 then
    begin
      Result := child;
      break;
    end;
    if (not UseFilter) or (child.NodeName = filter) then
      Dec(index);
    child := child.NextSibling;
  end;
end;
-------------------- end original --------------------------------------
This is not checking the filter value if index is 0 /GetItem(0)/. And
what about negative inices? It should be changed like this :

------------------ change like this ----------------------
function TDOMNodeList.GetItem(index: LongWord): TnDOMElement;
var
  child: TDOMNode;
begin
  Result := nil;
  if index < 0 then
    exit;
  child := node.FirstChild;
  while Assigned(child) do
  begin
    if ((index = 0) and (not UseFilter)) or
       ((index = 0) and (UseFilter) and (child.NodeName = filter)) then
       begin
         Result := TnDOMElement(child);
         break;
       end;

    if (not UseFilter) or (child.NodeName = filter) then
      Dec(index);
    child := child.NextSibling;
  end;
end;
---------- end change ----------------------------

Your comments please.
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to