XML special character bug

106 views
Skip to first unread message

nbato...@wings.rs

unread,
Apr 6, 2023, 8:23:24 PM4/6/23
to harbou...@googlegroups.com

Hi to all :)

 

I send this exampe to harbour-users, but nobody answered me. I think it's a bug in TXmlDocument class.

 

I have simple XML with attributes which contaings special characters  
  and 
 -- sample XML is in attach. This is important line:

 

<Stavke naziv="DETA-&#xD;&#xA;-1603"/>

 

For reading I use this simple code:

 

PROC Main

   CLS

   oDoc := TXmlDocument():new()

   oDoc:read(MemoRead("c:\tmp\pp.xml"))

   x1 := oDoc:findFirst ("Stavke")

   ? s1 := x1:aAttributes["naziv"]

   x2 := oDoc:findNext ()

   ? s2 := x2:aAttributes["naziv"]

   x3 := oDoc:findNext ()

   ? s3 := x3:aAttributes["naziv"]

RETURN

 

Result (characters for special symbols) change every time I start this program???

 

 

Thanks in advance,

 

Nenad Batocanin

 

image001.png
PP.xml

Adam Lubszczyk

unread,
Apr 12, 2023, 7:27:45 AM4/12/23
to Harbour Developers
TXmlDocument  use to parse xml   function from   ....\core\contrib\xhb\hbxml.c

Some fragment:
...
               else if( strncmp( bp, "apos", iAmpLen ) == 0 )
                  chr = '\'';
               else if( *bp == '#' )
               {
                  if( *( ++bp ) == 'x' ) /* Hexadecimal */
                     chr = ( ( *( bp + 1 ) - '0' ) << 4 ) + ( *( bp + 2 ) - '0' );
                  else                   /* Decimal */
                     chr = atoi( bp );
               }
....

So,  enity   type :   &#xHHHH;  
 -  must be equal 2 chars len
 -  buggly when use alpha A-F or a-f

 - enity  &#NNNN;    must be < 255  (no Unicode )
 
Adam

nbato...@wings.rs

unread,
Apr 14, 2023, 9:44:57 AM4/14/23
to harbou...@googlegroups.com

Many thanks to you and everyone who helped me clarify the problem!

 

For now, I solved the problem by doing StrTran before parsing the XML.

 

Regards, NB

--
You received this message because you are subscribed to the Google Groups "Harbour Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-deve...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-devel/b0e2dd2c-faa4-4764-ab1b-9171adb1714bn%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages