AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Netzwerke Delphi Getting error while parsing xml in XE4
Thema durchsuchen
Ansicht
Themen-Optionen

Getting error while parsing xml in XE4

Ein Thema von rabirabi · begonnen am 18. Apr 2014 · letzter Beitrag vom 19. Apr 2014
Antwort Antwort
rabirabi

Registriert seit: 7. Aug 2013
4 Beiträge
 
#1

Getting error while parsing xml in XE4

  Alt 18. Apr 2014, 16:35
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
  Mit Zitat antworten Zitat
rabirabi

Registriert seit: 7. Aug 2013
4 Beiträge
 
#2

AW: Getting error while parsing xml in XE4

  Alt 18. Apr 2014, 18:34
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.
  Mit Zitat antworten Zitat
Dejan Vu
(Gast)

n/a Beiträge
 
#3

AW: Getting error while parsing xml in XE4

  Alt 19. Apr 2014, 07:23
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.
  Mit Zitat antworten Zitat
rabirabi

Registriert seit: 7. Aug 2013
4 Beiträge
 
#4

AW: Getting error while parsing xml in XE4

  Alt 19. Apr 2014, 08:23
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.
  Mit Zitat antworten Zitat
mjustin

Registriert seit: 14. Apr 2008
3.004 Beiträge
 
Delphi 2009 Professional
 
#5

AW: Getting error while parsing xml in XE4

  Alt 19. Apr 2014, 08:54
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.
Michael Justin
  Mit Zitat antworten Zitat
rabirabi

Registriert seit: 7. Aug 2013
4 Beiträge
 
#6

AW: Getting error while parsing xml in XE4

  Alt 19. Apr 2014, 13:26
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.
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:53 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