Die Arbeit mit XML unter C++ Builder ist einfach und intuitiv. Allerdings sollte man beachten, immer brav auf das Interface zu programmieren 🙂
void TFormMain::ReplyRequestTest( void ) { TXMLDocument *XMLDocument = new TXMLDocument(this); XMLDocument->Options = XMLDocument->Options << doNodeAutoIndent; XMLDocument->Active = true; XMLDocument->Version = "1.0"; XMLDocument->Encoding = "ISO-8859-1"; _di_IXMLDocument IDocument; XMLDocument->GetInterface( IDocument ); _di_IXMLNode TerminalNode = IDocument->AddChild( "Test" ); TerminalNode->SetAttribute( "TerminalGuid", Setting->GetTerminalGuid() ); Logging->Write( XMLDocument->XML->Text ); this->ClientSocket->Socket->SendText( XMLDocument->XML->Text ); delete XMLDocument; } void TFormMain::ReplyRequestMessageChange( void ) { TXMLDocument *XMLDocument = new TXMLDocument(this); XMLDocument->Options = XMLDocument->Options << doNodeAutoIndent; XMLDocument->Active = true; XMLDocument->Version = "1.0"; XMLDocument->Encoding = "ISO-8859-1"; _di_IXMLDocument IDocument; XMLDocument->GetInterface( IDocument ); _di_IXMLNode TerminalNode = IDocument->AddChild( "Message" ); TerminalNode->SetAttribute( "TerminalGuid", Setting->GetTerminalGuid() ); TerminalNode->SetAttribute( "MessageGuid", ClientDataSetTerminalMessageGuid->AsString ); TerminalNode->SetAttribute( "MessageAcronym", ClientDataSetTerminalMessageAcronym->AsString ); Logging->Write( XMLDocument->XML->Text ); this->ClientSocket->Socket->SendText( XMLDocument->XML->Text ); delete XMLDocument; }