3

I try to load a node only to face the EInvalidPointer error on Delphi.

My "xml" goes this way:

<RYCFile>
    <GeneralInfo>
        <SystemName/>
        <NSpecies>1</NSpecies>
        <NMaxCriterias>2</NMaxCriterias>
    <MaxRating>1</MaxRating>
        <SystemType>0</SystemType>
        <EvolutivePointCost>1</EvolutivePointCost>
    </GeneralInfo>
    <Race Index="1">
        <RaceName>Race #1</RaceName>
        <NumCriterias>2</NumCriterias>
        <Criteria Index="1">
            <Name>Criteria #1</Name>
                <NSubCriterias>0</NSubCriterias>
                <Limiter>0</Limiter>
            </Criteria>
            <Criteria Index="2">
                <Name>Criteria #2</Name>
                <NSubCriterias>0</NSubCriterias>
                <Limiter>0</Limiter>
            </Criteria>
        </Race>
</RYCFile>

I can't even read the DocumentElement.

I've googled everywhere but I'm at wit's end, it seems. Can't seem to find a solution remotely adapted to what I'm enduring.

Code used to "read":

FormSkeletonMaker.XMLDocumentFile.LoadFromFile(FileName);
FormSkeletonMaker.XMLDocumentFile.Active := True;
iNode := FormSkeletonMaker.XMLDocumentFile.ChildNodes.FindNode('GenInfo');

right now it goes this way. I'm barely testing the ability for this document to get loaded (it was made on the same program).

2
  • I updated the original post. Far more readable. Commented Apr 1, 2012 at 2:36
  • please use four spaces instead of "> " to format code Commented Apr 2, 2012 at 0:15

1 Answer 1

4

If the DocumentElement property fails, then either the FormSkeletonMaker or XMLDocumentFile object pointer is invalid.

Sign up to request clarification or add additional context in comments.

3 Comments

The Form can't be the one behind it. I chose to make XMLDocumentFile a component in my program (no dynamic loading or anything). If anything, I try Showmessage(XMLDocumentFile.XML.Text); and I get the whole xml.
It seems you're right. Somewhere the XMLDocumentFile went astray - I treated it like a dynamic one while it was static. Bad, bad error. The old code I tried out was using dynamic stuff and it didn't work simply because I had to create the xml document.
If you create a TXMLDocument dynamically without an Owner specified, it acts as a reference-counted interface (this is stated as much in the documentation), so you have to be extra careful of that. Better to use the NewXMLDocument() and LoadXML...() functions instead, which return an IXMLDocument interface.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.