Alcinoe icon indicating copy to clipboard operation
Alcinoe copied to clipboard

TALXMLDocument & C++Builder 10.3

Open antarey opened this issue 5 years ago • 5 comments
trafficstars

I have several problems using your products. I am creating a new project. Add to the project group ALXmlDoc.pas. When compiling a project, the error: Compiling Project1.cbproj (Debug, Win32)

[bcc32 Error] ALXmlDoc.hpp(166): E2238 Multiple declaration for 'TALXMLNodeList::Nodes'
  Full parser context
    Unit1.cpp(7): #include ALXmlDoc.hpp
    ALXmlDoc.hpp(24): namespace Alxmldoc
    ALXmlDoc.hpp(119): class TALXMLNodeList
[bcc32 Error] ALXmlDoc.hpp(165): E2344 Earlier declaration of 'TALXMLNodeList::Nodes'
  Full parser context
    Unit1.cpp(7): #include ALXmlDoc.hpp
    ALXmlDoc.hpp(24): namespace Alxmldoc
    ALXmlDoc.hpp(119): class TALXMLNodeList
	__property TALXMLNode* Nodes[const System::AnsiString Name] = {read=GetNodeByName/*, default*/};
	__property TALXMLNode* Nodes[const int Index] = {read=GetNodeByIndex};

If you comment out a line __property TALXMLNode* Nodes[const int Index] = {read=GetNodeByIndex}; the project works. But I can not call Node by index to iterate over the loop. I want to trigger the OnParseText event. In *.h file add void __fastcall OnParseText(System::TObject* Sender, const System::AnsiString Path, const System::AnsiString Str); In *.cpp add

//---------------------------------------------------------------------------
void __fastcall TForm1::OnParseText(System::TObject* Sender, const System::AnsiString Path, const System::AnsiString Str)
{

}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TALXMLDocument* aXMLDocument = new TALXMLDocument("root");
aXMLDocument->OnParseText = OnParseText;
aXMLDocument->LoadFromFile("d:\\28-ex_xml_atu.xml");
}
//---------------------------------------------------------------------------

Error

[bcc32 Error] Unit1.cpp(30): E2235 Member function must be called or its address taken
  Full parser context
    Unit1.cpp(27): parsing: void _fastcall TForm1::Button1Click(TObject *)

How to properly trigger the OnParseText event? Do you have your own website and forum? thanks for the help

antarey avatar May 20 '20 06:05 antarey

	__property TALXMLNode* Nodes[const System::AnsiString Name] = {read=GetNodeByName/*, default*/};
	__property TALXMLNode* Nodes[const int Index] = {read=GetNodeByIndex};

are overloaded properties. Does c++ builder support overload properties? I Need to say I never try it on c++ builder :(

Zeus64 avatar May 20 '20 07:05 Zeus64

Does c++ builder support overload properties? Yes. Since I can’t access the OnParseText event, how to process a file in a loop?

aXMLDocument.LoadFromFile('d:\Users\antarey\Downloads\28-ex_xml_atu.xml', False);

       for I := 0 to aXMLDocument.Node.ChildNodes.Nodes['DATA'].ChildNodes.Count do begin
        OBL_NAME = aXMLDocument->Node->ChildNodes->Nodes["DATA"]->ChildNodes->Nodes["RECORD"]->ChildNodes->Nodes["OBL_NAME"]->NodeValue;     **????** 
    MemoParseXmlWithALXmlDocumentInSaxMode.Lines.Add(OBL_NAME );
    end;

antarey avatar May 20 '20 07:05 antarey

	__property TALXMLNode* Nodes[const System::AnsiString Name] = {read=GetNodeByName/*, default*/};
	__property TALXMLNode* Nodes[const int Index] = {read=GetNodeByIndex};

are overloaded properties. Does c++ builder support overload properties? I Need to say I never try it on c++ builder :(

  property Nodes[const Name: AnsiString]: TALXMLNode read GetNodeByName; default;
   property Nodes[const Index: integer]: TALXMLNode read GetNodeByIndex; default;

There is no overload in your code

antarey avatar May 20 '20 08:05 antarey

you need both properties

__property TALXMLNode* Nodes[const System::AnsiString Name] = {read=GetNodeByName/*, default*/};
__property TALXMLNode* Nodes[const int Index] = {read=GetNodeByIndex};

else, of course, you can not access node by index (or by name). in Delphi you don't need to add the word overload in front of the property and it's even not possible (compiler error if you do so)! Seam there is an incompatibility on this point with Delphi/c++ builder

Zeus64 avatar May 20 '20 08:05 Zeus64

__property TALXMLNode* **NodesByName**[const System::AnsiString Name] = {read=GetNodeByName/*, default*/};
__property TALXMLNode* Nodes[const int Index] = {read=GetNodeByIndex};

antarey avatar May 22 '20 05:05 antarey