[fpc-pascal] XML Iteration

Frank Church vfclists at googlemail.com
Sun May 2 08:59:37 CEST 2010


I am having some problems with XPath.

EvaluateXPathExpression raises exceptions with some search strings and I am
not sure if it is my limited knowledge of XPath, or a buggy XPath
implementation.

The attached demo uses the example from
http://www.w3schools.com/xpath/xpath_examples.asp and I am running 0.9.28.2
beta on Windows


On 29 April 2010 03:08, Luiz Americo Pereira Camara <luizmed at oi.com.br>wrote:

> Lee Jenkins escreveu:
>
>  Luiz Americo Pereira Camara wrote:
>>
>>> Frank Church escreveu:
>>>
>>>> I am glad to see someone with an interest in FPCs XML. Do you have
>>>> some experience with XPath usage in PFC/Lazarus?
>>>>
>>>>
>>>>
>>>
>>>
>> Luiz,
>>
>> In Unit1.pas:
>>
>> XPathResult := EvaluateXPathExpression('//Descricao',
>> XmlTree.DocumentElement);
>>  if (XPathResult <> nil) then
>>  begin
>>    for i := 0 to XPathResult.AsNodeSet.Count - 1 do
>>    begin
>>      Node := TDOMNode(XPathResult.AsNodeSet[i]);
>>      if Node.FirstChild <> nil then
>>        Memo1.Lines.Add(UTF8Encode(Node.FirstChild.NodeValue));
>>    end;
>>    XPathResult.Destroy;
>>  end;
>>  XmlTree.Free;
>>
>>
>> Why the call to XPathResult.Destroy ?  Is it for reference counting?  Just
>> seems something else to remember (use destroy instead of free)...
>>
>
> No special reason.
>
> Free is redundant in this case since i already knows that XPathResult <>
> nil
>
> Luiz
>
>
>
>> Thanks
>>
>> --
>> Warm Regards,
>>
>> Lee
>> _______________________________________________
>> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
>> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>>
>>
>>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>



-- 
Frank Church

=======================
http://devblog.brahmancreations.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20100502/1f6285d5/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: prjXPath.zip
Type: application/zip
Size: 3102 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20100502/1f6285d5/attachment.zip>


More information about the fpc-pascal mailing list