[fpc-pascal] fcl-xml

Daniel Gaspary dgaspary at gmail.com
Tue Mar 12 15:17:08 CET 2013


Using Xpath I believe would be something like this:

function ElementById(id: string; doc: TXMLDocument): TDOMElement;
var
   v: TXPathVariable;
begin
     result:=nil;
     try
        v:=EvaluateXPathExpression('//*[@id=' + QuotedStr(id)+']',
             doc.DocumentElement);

        result:=TDOMElement(v.AsNodeSet[0]);
     finally
            FreeAndNil(v);
     end;
end;

On Tue, Mar 12, 2013 at 10:42 AM,  <dev.dliw at gmail.com> wrote:
> A little side note to my statement:
>> and I don't have a DTD
>
> In this case the behaviour of the parser is even right...
>
> W3C:
> Note: Attributes with the name "ID" or "id" are not of type ID unless so
> defined
> ----------------------
> http://stackoverflow.com/questions/3423430/java-xml-dom-how-are-id-attributes-special
>
> But that's not the solution to my problem... :(
> d.l.i.w
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal



More information about the fpc-pascal mailing list