Bug? The XML was improperly formatted. Please escape it if necessary

Saverio

Member
Licensed User
Longtime User
Hi! Erel,

I'm using B4A v3.82, windows7 sp1, and got the following problem:



As you can see the hint show the problem but...


So the problem happen when I use the "Less than" sign.
As you can see, instead, using the "Greater than" sign, the hint work properly.

The questions are:
1. Is this a bug?
2. I'm doing something wrong
3. A comment, doesn't should be a "comment", no matter what inside?

You said "Please escape it if necessary", yes I could, but I will get an hint which is not user-friendly
Regards
 

eps

Expert
Licensed User
Longtime User
< and > are illegal characters in xml, this has nothing to do with B4A. You should escape it ( < as &lt; and > as &gt; ).

< and > are legal characters in XML.... It's a little odd that the parser thinks that you've started to code XML within B4A - seems like a bug to me. Will see what Erel says....
 

barx

Well-Known Member
Licensed User
Longtime User
This question has been asked before, including by myself. < must be replaced by &lt; as stated. Otherwise the compiler will mistake it, probably for a nested element.
 
Reactions: eps

eps

Expert
Licensed User
Longtime User
This question has been asked before, including by myself. < must be replaced by &lt; as stated. Otherwise the compiler will mistake it, probably for a nested element.

Very good, thanks for confirming. I haven't seen it before.
 

MaFu

Well-Known Member
Licensed User
Longtime User
< and > are legal characters in XML.... It's a little odd that the parser thinks that you've started to code XML within B4A - seems like a bug to me. Will see what Erel says....
This is not correct. < and > are NOT legal in xml and must be escaped. And there's nothing odd. B4A use the standard .NET classes to interpret the xml data (imho) and therefore the xml must be well formattet. Why should Erel reinvent the wheel?
 

eps

Expert
Licensed User
Longtime User
This is not correct. < and > are NOT legal in xml and must be escaped. And there's nothing odd. B4A use the standard .NET classes to interpret the xml data (imho) and therefore the xml must be well formattet. Why should Erel reinvent the wheel?

Ah, I think I understand the confusion now.. < and > are legal characters in xml but not within xml statements.
 

Saverio

Member
Licensed User
Longtime User
< and > are illegal characters in xml, this has nothing to do with B4A. You should escape it ( < as &lt; and > as &gt; ).

I have tried &lt and &gt, both aren't working for me.

And I think it is a B4A precisely matter.
Should be B4A to convert any needed substitution in the xml code.
I don't know nothing about xml, I'm just using B4A.

Please can you provvide a concrete example, "exactly", related to my question?

Thank you
 

LucaMs

Expert
Licensed User
Longtime User
I have no idea. But think about what problem for a single character (free app!!!).

Just one thing: if it were a matter of "legality" of those characters, the problem should be with both of them, with one of them instead the problem does not occur (">").
 

Saverio

Member
Licensed User
Longtime User

Ciao Luca,
Yeah! you got the target.

Why "<" is wrong for xml and, instead, ">" don't
Someone said that both are wrong.
I'm getting confused.
 

MaFu

Well-Known Member
Licensed User
Longtime User
Normally both are wrong. No idea why > works. But this have nothing to do with B4A. This escaping is same syntax as in html. Use always the escaped version and you're on the right side.
 

Saverio

Member
Licensed User
Longtime User
Normally both are wrong. No idea why > works. But this have nothing to do with B4A. This escaping is same syntax as in html. Use always the escaped version and you're on the right side.
Thank you for reply MaFu. Now I understad a bit more!

So, in short, the trick is:

Working comment
B4X:
'Example1 IIf(3 > 4, "Correct", "Wrong") will Return "Wrong"
Sub IIf(QuestionTrue As Boolean, TruePart As Object, FalsePart As Object) As Object
    If QuestionTrue Then Return TruePart
    Return FalsePart
End Sub

Not working comment
B4X:
'Example1 IIf(3 < 4, "Correct", "Wrong") will Return "Correct"
Sub IIf(QuestionTrue As Boolean, TruePart As Object, FalsePart As Object) As Object
    If QuestionTrue Then Return TruePart
    Return FalsePart
End Sub


The Trick working for both comment
B4X:
'Example1 IIf(3 &gt; 4, "Correct", "Wrong") will Return "Correct"
'Example2 IIf(3 &lt; 4, "Correct", "Wrong") will Return 4
Sub IIf(QuestionTrue As Boolean, TruePart As Object, FalsePart As Object) As Object
    If QuestionTrue Then Return TruePart
    Return FalsePart
End Sub


But, once again, as I said in the post #1, even get it working in the "Baloon",
upon the subroutine, still not user-friendly.

I think B4A, can do, easily, the translation. But this is just a wish

** NOTE ** For all those will read this thread, I remind them that we are talking about the
comment upon the subroutine that will be shown in the hint(baloon) at the program time.
The Code inside the subroutine still working, no matter whether the comment is working or not.
 
Last edited:

eps

Expert
Licensed User
Longtime User
< starts to open up an XML structure whereas > is an ending XML structure so the both are processed differently as I suspect the parser and compiler encounter them and consider them differently.
 

MaFu

Well-Known Member
Licensed User
Longtime User
But, once again, as I said in the post #1, even get it working in the "Baloon",
upon the subroutine, still not user-friendly.

I think B4A, can do, easily, the translation. But this is just a wish
But how should this work?
The .net framework loads and parses the xml. B4A sees only the already parsed result, on this time it's to late. Only the tool which creates the xml can do the correction.
 

Saverio

Member
Licensed User
Longtime User
But how should this work?
The .net framework loads and parses the xml. B4A sees only the already parsed result, on this time it's to late. Only the tool which creates the xml can do the correction.

Considering that B4A knows which line is a comment and which don't, I think, it's possible,
before performing the "Save" function, translate, in the comment lines only, those characters which
needs to be "escaped" and set back them at reload time, leaving the IDE buffer text as it is.
I'm not a programmer and don't want teach none.
This is how I would do it if the source code would my.
 

James Chamblin

Active Member
Licensed User
Longtime User
Cookies are required to use this site. You must accept them to continue using the site. Learn more…