On Fri, 10 Aug 2007 15:40:49 +0200
Marco van de Voort <[EMAIL PROTECTED]> wrote:
>
> At work I also use laz_xmlcfg from Delphi, and I noticed that while
> it can parse the following format, there is no way to retrieve the
> value "1000".
>
> <!--- cutout, imagine std XML header here >
> <connectivity>
> <answer_timeout id="2">1000</answer_timeout>
> </connectivity>
>
> The value is read into a #text child, but that is not queryable
> because the last value in a getvalue path is always searched in the
> attributes node.
>
> The following patch is a possible solution for that:
>
> Index: C:/cansrc/libraries/lumen16/laz_xmlcfg.pas
> ===================================================================
> --- C:/cansrc/libraries/lumen16/laz_xmlcfg.pas (revision 330)
> +++ C:/cansrc/libraries/lumen16/laz_xmlcfg.pas (revision 344)
> @@ -139,7 +139,7 @@
>
> function TXMLConfig.GetValue(const APath, ADefault: String): String;
> var
> - Node, Child, Attr: TDOMNode;
> + m,Node, Child, Attr: TDOMNode;
> NodeName: String;
> PathLen: integer;
> StartPos, EndPos: integer;
> @@ -179,7 +179,12 @@
> //writeln('TXMLConfig.GetValue G2 NodeName="',NodeName,'"');
> Attr := Node.Attributes.GetNamedItem(NodeName);
> if Assigned(Attr) then
> - Result := Attr.NodeValue;
> + Result := Attr.NodeValue
> + else
> + begin
> + m:=node.FindNode('#text');
> + if assigned(m) then result:=m.NodeValue;
> + end;
> //CheckHeapWrtMemCnt('TXMLConfig.GetValue H');
> //writeln('TXMLConfig.GetValue END Result="',Result,'"');
> end;
This would mean '1000' becomes the default value for all attributes,
right?
For example GetValue('connectivity/answer_timeout/tag',2) will return
1000 instead of 2.
Mattias
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives