Author |
Message
|
Sneh4nsu |
Posted: Wed Oct 25, 2017 10:14 am Post subject: Parser error while parsing special characters using XMLNSC |
|
|
Novice
Joined: 11 Aug 2017 Posts: 12
|
Code: |
DECLARE my_xml CHARACTER '<tag>&</tag>';
CREATE LASTCHILD OF OutputRoot DOMAIN('XMLNSC')
PARSE(my_xml,546,1208); |
Throwing 'An xml parsing error has occurred' but instead if I parse <tag>hello</tag> it is getting parsed. As far as I know the XLMNSC parser escape the special characters(here &) to &
Please help me!! |
|
Back to top |
|
 |
Vitor |
Posted: Wed Oct 25, 2017 10:23 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
What happens if you try:
Code: |
CREATE LASTCHILD OF OutputRoot DOMAIN('XMLNSC') NAME 'tag' VALUE '&'; |
_________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Sneh4nsu |
Posted: Wed Oct 25, 2017 10:43 am Post subject: |
|
|
Novice
Joined: 11 Aug 2017 Posts: 12
|
Vitor wrote: |
What happens if you try:
Code: |
CREATE LASTCHILD OF OutputRoot DOMAIN('XMLNSC') NAME 'tag' VALUE '&'; |
|
Output is having no value
My question is does XMLNSC parser automatically escape special characters or we need to specify certain encodings
In my case Im having a large string with some special characters.
Help needed |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Oct 25, 2017 10:45 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Sneh4nsu wrote: |
Vitor wrote: |
What happens if you try:
Code: |
CREATE LASTCHILD OF OutputRoot DOMAIN('XMLNSC') NAME 'tag' VALUE '&'; |
|
Output is having no value
My question is does XMLNSC parser automatically escape special characters or we need to specify certain encodings
In my case Im having a large string with some special characters.
Help needed |
If you do it right the XMLNSC parser will escape the special characters for you.
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Vitor |
Posted: Wed Oct 25, 2017 11:10 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Sneh4nsu wrote: |
Output is having no value |
Then there's a bug in my code
Sneh4nsu wrote: |
My question is does XMLNSC parser automatically escape special characters |
Yes
Sneh4nsu wrote: |
or we need to specify certain encodings |
No _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Sneh4nsu |
Posted: Wed Oct 25, 2017 11:13 am Post subject: |
|
|
Novice
Joined: 11 Aug 2017 Posts: 12
|
Vitor wrote: |
Sneh4nsu wrote: |
Output is having no value |
Then there's a bug in my code
Sneh4nsu wrote: |
My question is does XMLNSC parser automatically escape special characters |
Yes
Sneh4nsu wrote: |
or we need to specify certain encodings |
No |
every time I execute the code I am getting this:'The entity name must immediately follow the '&' in the entity reference'
I guess the parser is looking for & |
|
Back to top |
|
 |
timber |
Posted: Wed Oct 25, 2017 1:09 pm Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
Let me get this straight. You are executing this code:
Code: |
DECLARE my_xml CHARACTER '<tag>&</tag>';
CREATE LASTCHILD OF OutputRoot DOMAIN('XMLNSC')
PARSE(my_xml,546,1208); |
and you are surprised that you are getting an error?!
Please do this.
1. Put that XML into a file with extension '.xml'
2. Open that XML file in your favourite web browser
What does the web browser's XML parser say?
If you want additional proof, try the XML parser from any other product.
IIB escapes special characters when writing XML. It does not auto-magically fix broken XML documents when parsing. Instead, it correctly points out that your XML is badly-formed. |
|
Back to top |
|
 |
|