[Lazarus] How to get the package version from a LPK file?
graemeg.lists at gmail.com
Tue Nov 29 07:53:51 CET 2011
On 28/11/2011, silvioprog <silvioprog at g....> wrote:
> I'm trying, trying, trying, but without sucess. x(
> Find attached, my test example. It uses DOM and XML Reader.
> If someone can see where I'm missing in this project, please show me
> where the error is.
F*cken hell, now I know why I don't EVER use or work with XML! I had
a look at your code, and the problem is seemingly easy, but the
solution is definitely not. I tried DocumentElement,
.GetElementsByName(), FindNode(), FirstChild() etc... Not a single one
returns what I would have expected - most functions simply returned
nil. TDOMNode.FindNode() doesn't even have an implementation.
I then thought I would look at Lazarus's TXMLConfig - because surely
that uses the DOM to find values. To my surprise, that component
implements it's own recursive iteration over nodes to find something -
and it's not easy on the eyes. So what the hell is the point of the
DOM or TXMLDocument implementation if none of the default
implementation can do any searching.
Sorry I tried. I'll leave XML to the really clever people (or rather
the insane people for wanting to use XML). I'll stick to INI (or
maybe even JSON) files thank you very much. :)
And to be clear, as a programmer, this is the API interface I would
expect to use... which I don't think is unreasonable. Obviously this
doesn't work, but hey, that's XML for you.
ReadXMLFile(VXML, ExtractFilePath(ParamStr(0)) + 'LazSolutionsDT.lpk');
n := vxml.FindNode('/Config/Package/Version');
I doubt you can simply search for 'Version', because that node name
appears in a few location in the XML hierarchy. So you would somehow
need to tell it you are looking for '/Config/Package/Version'.
- Graeme -
fpGUI - a cross-platform Free Pascal GUI toolkit
More information about the Lazarus