[DUG] Strange Error in Android
Jeremy Coulter
jscoulter at gmail.com
Fri Dec 6 13:26:49 NZDT 2013
OK! I found the problem! There is maybe a bug when you are using
LoadXMLData(). The first line of the XMl file <?xml version='1.0' encoding
= 'UTF-8' ?> - not the space before and after the "=" in the "encode"
element?? yip thats right, the spaces thew the error! take them out, and
hey presto it works! Yet loading from file it doesn't care!
To me that's a bug, but there could also be some explanation. BTW, this
made no diff. using Android or Win32
Jeremy
On Thu, Dec 5, 2013 at 1:12 PM, Jeremy Coulter <jscoulter at gmail.com> wrote:
> Ok, so what I did was put the source code onto my dev backup VM on my
> laptop and connected to the AP then sent the commands to the server to get
> the XML returned.
> If I use "LoadXMLData()" it still fails but tells me its expecting a"?" or
> "white space" on "line:1" which has the <?XML....blah blah?> on it. I have
> a sneaky suspicion I might know what it is, and will be looking tonight and
> will report back
>
> Jeremy
>
>
> On Wed, Dec 4, 2013 at 11:37 AM, Jeremy Coulter <jscoulter at gmail.com>wrote:
>
>> hmm...well that could be. I am just perplexed why its fine when the data
>> in the string (or DOMString) variable is written then read from a file, and
>> what is different there as apposed to reading it from a string directly.
>> Bloody annoying!
>>
>> Jeremy
>>
>>
>> On Wed, Dec 4, 2013 at 11:16 AM, Jolyon Smith <jsmith at deltics.co.nz>wrote:
>>
>>> CR, LF CR+LF - all are whitespace in XML unless in a CDATA but since the
>>> error is occurring before the parser has even dealt with the <?xml>
>>> declaration CDATA sections are not likely to be in play here. If the
>>> Embarcadero parser on Android is broken by variations in whitespace I would
>>> think twice about trusting it with anything really complicated. You know,
>>> like actual XML. ;)
>>>
>>> Jeremy Coulter <jscoulter at gmail.com>
>>> Wed, 4 Dec 2013 10:27
>>> Thanks for the replies. I was away yesterday, but I THINK John might be
>>> on the right track. I will be checking it out and will report back.
>>>
>>> Jeremy
>>>
>>>
>>>
>>> _______________________________________________
>>> NZ Borland Developers Group - Delphi mailing list
>>> Post: delphi at listserver.123.net.nz
>>> Admin: http://delphi.org.nz/mailman/listinfo/delphi
>>> Unsubscribe: send an email to delphi-request at listserver.123.net.nz with
>>> Subject: unsubscribe
>>> Jolyon Smith <jsmith at deltics.co.nz>
>>> Tue, 3 Dec 2013 10:50
>>>
>>> Could you post the first line of the XML so we can see what it comprises
>>> of ? i.e. what XML declaration does the string contain which the parser is
>>> rejecting ?
>>>
>>> As a result of the DOM Vendor implementation model in Delphi, behaviour
>>> on Windows is no indication of reliability on Android, iOS or OS X (as you
>>> are finding).
>>>
>>> For Android it seems that the key to your problem is in
>>> XML.Internal.AdomCore_4_3.pas, specifically the EvaluateXmlOrTextDecl()
>>> method of TXmlInputSource but without knowing what declaration is being
>>> presented to this method it's impossible to say whether the problem lies
>>> here, in the process of assigning the string from the HTTP response to the
>>> XML document or with the content of the XML string itself.
>>>
>>> There is potential for many slips twixt this particular cup and lip.
>>>
>>> Robert Martin <rob at chreos.co.nz>
>>> Tue, 3 Dec 2013 09:03
>>> Hi Jeremy
>>>
>>> Never done any Delphi Android work but is it possible it is a character
>>> set issue? I am only using XE2 nut if I look at XMLDoc.LoadFromXML() (I
>>> don't have a LoadXMLData) it takes an AnsiString on at UTF16 delphi string.
>>>
>>> Thanks
>>> Rob
>>>
>>>
>>> On 2/12/2013 11:40 p.m., Jeremy Coulter wrote:
>>>
>>> _______________________________________________
>>> NZ Borland Developers Group - Delphi mailing list
>>> Post: delphi at listserver.123.net.nz
>>> Admin: http://delphi.org.nz/mailman/listinfo/delphi
>>> Unsubscribe: send an email to delphi-request at listserver.123.net.nz with
>>> Subject: unsubscribe
>>> Jeremy Coulter <jscoulter at gmail.com>
>>> Mon, 2 Dec 2013 23:40
>>>
>>> Hi All.
>>>
>>> I am Sending an HTTP request to a server that is returning some XML in
>>> an Android app.
>>>
>>> However, I get an unexpected result. I am using Indy and the
>>> idHTTP.get() function which returns either a string or populates a stream.
>>>
>>> I started out first by loading the results into a string variable, i.e.
>>> buffer:=isHTTP.get() which returns the data fine, BUT if I call
>>> LoadXMLData(buffer) - (LoadXmlData() is in Xml.XMLDoc.pas) which is a
>>> function I have used a number of time in Delphi in normal Windows apps and
>>> never had a problem – that wasn’t something I did J
>>>
>>> However, if in the android app, I load the buffer variable into a string
>>> list then save that to file the call LoadXMLDocument() that takes a file
>>> name, it works fine !!
>>>
>>> Oh, the error I get is “ET_INVALID_XML_DECL line:-1” which indicates
>>> the XML is invalid but if I do a showmessage(buffer) its perfectly fine.
>>>
>>> I have tried loading the result into a stream and the reading it out
>>> into a string and I get the same error. I have tried removing the #13#10’s
>>> and STILL I get the error. If I write the XML to file first, no problem.
>>>
>>> I have tried using String and DOMStrings, but still the same error
>>>
>>>
>>>
>>> Anyone got any ideas? I shouldn’t have to write the xml to file then
>>> load it, that’s a bit of a pain.
>>>
>>>
>>>
>>>
>>>
>>> Thanks, Jeremy
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> NZ Borland Developers Group - Delphi mailing list
>>> Post: delphi at listserver.123.net.nz
>>> Admin: http://delphi.org.nz/mailman/listinfo/delphi
>>> Unsubscribe: send an email to delphi-request at listserver.123.net.nz with
>>> Subject: unsubscribe
>>>
>>>
>>> _______________________________________________
>>> NZ Borland Developers Group - Delphi mailing list
>>> Post: delphi at listserver.123.net.nz
>>> Admin: http://delphi.org.nz/mailman/listinfo/delphi
>>> Unsubscribe: send an email to delphi-request at listserver.123.net.nz with
>>> Subject: unsubscribe
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20131206/25a5d567/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 770 bytes
Desc: not available
Url : http://listserver.123.net.nz/pipermail/delphi/attachments/20131206/25a5d567/attachment.jpe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 1302 bytes
Desc: not available
Url : http://listserver.123.net.nz/pipermail/delphi/attachments/20131206/25a5d567/attachment-0001.jpe
More information about the Delphi
mailing list