I am across a problem while parsing xml document. Actually I am using XMl Binding wizard to extract the attributes values but every time it throws exceptions.
Here is my xml:
<?xml version="1.0" encoding="UTF-8"?>
<conversioncloud version="1.2">
<status step="finished"/>
<id>
<![CDATA[T9Nr96Hy]]>
</id>
<videoid>
<![CDATA[92590917]]>
</videoid>
<server>
<![CDATA[server12]]>
</server>
<file>
<![CDATA[my file ofr xmfhf.ext]]>
</file>
<service>
<![CDATA[myservice]]>
</service>
<mediaurl>
<![CDATA[web address here]]>
</mediaurl>
<downloadurl>
<![CDATA[download url here]]>
</downloadurl>
<downloadserver>
<![CDATA[srv55]]>
</downloadserver>
<downloadhash>
<![CDATA[upyxqnJmsKuwbGttn5OcaXCs26SqaG60l5acbmpmm2pka7WEz9bXnaeE14ujqK2tyMg%3D]]>
</downloadhash>
<filesize>
<![CDATA[2.77 MB]]>
</filesize>
<debuginfo>
<![CDATA[T9Nr96Hy|92590917|srv55|1396163808|ListenToYoutube]]>
</debuginfo>
</conversioncloud>
My Code :
procedure TForm1.Button10Click(Sender: TObject);
var
Cloud : IXMLConversioncloudType;
size : Integer;
begin
XMLDocument1.XML.Text := Memo1.Text;
Cloud := Getconversioncloud(XMLDocument1);
// trying to display "file" field from xml document above
ShowMessage(Cloud.File_);
end;
Every time I get error : An opening '[' character was expected Line:23
Any fragment of code or suitable links will be appreciated.
EDIT: Thanks, But my limited knowledge in Delphi couldn't catch the posted instructions.By the way, This xml binding seems to be valid in C++ Builder 6. Using xml binding, I am able to extract the required fields like downloadurl, mediaurl, file, etc. from the same xml. Here is the code in C++ Builder 6.
void __fastcall YoutubeMax::ShowFileInfo(String aResponse)
{
frmMain->XMLDocument1->XML->Text = aResponse;
_di_IXMLconversioncloudType cloud = Getconversioncloud(frmMain->XMLDocument1);
// find index of files
int url = cloud->ChildNodes->IndexOf("downloadurl");
int title = cloud->ChildNodes->IndexOf("file");
int size = cloud->ChildNodes->IndexOf("filesize");
// Fill the details
frmMain->lblYoutubeFilename->Caption = "Title : " + cloud->ChildNodes->Nodes[title]->ChildNodes->Nodes[0]->Text;
frmMain->lblYoutubeFileSize->Caption = "File Size : " + cloud->ChildNodes->Nodes[size]->ChildNodes->Nodes[0]->Text;
frmMain->memoYoutubeMp3Link->Text = cloud->ChildNodes->Nodes[url]->ChildNodes->Nodes[0]->Text;
I don't know why the same logic doesn't work in delphi xe4. By the way the xml is valid since it opens normally in Internet explporer and Chrome. If you have any other methods to parse this xml then please do post reply.