Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Delphi Getting error while parsing xml in XE4 (https://www.delphipraxis.net/180046-getting-error-while-parsing-xml-xe4.html)

rabirabi 18. Apr 2014 16:35

Getting error while parsing xml in XE4
 
Greetings..
I am a student and enjoy learning delphi. I came across a problem while I am trying to extract data from a xml file using XML binding in Delphi XE-4. The problem is the application throws exception every time.

Here is my XML:
Code:
<?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>

Error I get as Exception: An opening '[' character was expected Line:23


Here is my code:
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;

Actually I want to extract the values like mediaurl, fileurl, filesize and so on.
PS I don't know whether this is the correct section to post this thread but I use Indy to get this xml data.

Thanks in Advance

rabirabi 18. Apr 2014 18:34

AW: Getting error while parsing xml in XE4
 
By the way I need a simpler solution i.e. using XML Binding wizard or any other methods. Any code example or reference for such problems will be appreciated.

Dejan Vu 19. Apr 2014 07:23

AW: Getting error while parsing xml in XE4
 
How do you store the XML? Don't use a TMemo, it breaks the lines and might produce an invalid XML.
I validated your XML and it passed, so actually there is nothing wrong with it.

rabirabi 19. Apr 2014 08:23

AW: Getting error while parsing xml in XE4
 
Hi,
I am using this as only a sample. In the real world I hava xml in string which is something like this:

Code:
IdHttp1.Post('http://MyAPIurl', Params, PostResponseinXML);
where,
Code:
Params is the stringlist containing parameters to send to the server,
PostResponseinXML is the StringStream received successfully after post.
while parsing this XMl I am getting error.

mjustin 19. Apr 2014 08:54

AW: Getting error while parsing xml in XE4
 
Zitat:

Zitat von rabirabi (Beitrag 1256190)
By the way I need a simpler solution i.e. using XML Binding wizard or any other methods. Any code example or reference for such problems will be appreciated.

Do you have a XSD?

The XML Schema Binding Wizards works best with an XSD.

If you have Delphi Enterprise or higher, you can also use the XML Data Binding Wizard.

rabirabi 19. Apr 2014 13:26

AW: Getting error while parsing xml in XE4
 
Zitat:

Zitat von mjustin (Beitrag 1256217)
Zitat:

Zitat von rabirabi (Beitrag 1256190)
By the way I need a simpler solution i.e. using XML Binding wizard or any other methods. Any code example or reference for such problems will be appreciated.

Do you have a XSD?

The XML Schema Binding Wizards works best with an XSD.

If you have Delphi Enterprise or higher, you can also use the XML Data Binding Wizard.

yes, I am using XML Binding wizard. The same problem using with XSD.


Alle Zeitangaben in WEZ +1. Es ist jetzt 07:31 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz