|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Escaping < while parsing the data against XMLNSC domain |
« View previous topic :: View next topic » |
Author |
Message
|
najmaaaa |
Posted: Sun Feb 19, 2012 5:38 am Post subject: Escaping < while parsing the data against XMLNSC domain |
|
|
Newbie
Joined: 19 Feb 2012 Posts: 4
|
Hi,
We expect an XML from the source system which can have & and <. So, the data is not a valid XML.
I am able to escape & and parse the data against XMLNSC domain. However, I am not able to escape < symbol that comes in the data. If I try replacing all < symbols that is present in the data to < and then parse against XMLNSC, it throws error.
For example, my data would look like,
<root><child>abc<def</child></root>
Need to make this as a perfect XML like below.
<root><child>abc<def</child></root>
SET varDATAContent = REPLACE(CAST(source.MRM.GenericData AS CHAR ), '&', '&');
--SET varDATAContent = REPLACE(varDATAContent, '<', '<');
CREATE LASTCHILD OF Data1 DOMAIN('XMLNSC') PARSE(CAST(varDATAContent AS BLOB CCSID 437 ENCODING 546));
It throws error if I uncomment the line that is commented in the above piece of code.
Can anyone help me in solving this problem.
Thank You,
Najma |
|
Back to top |
|
 |
smdavies99 |
Posted: Sun Feb 19, 2012 5:54 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Get the sending system to actually send a valid XML string.
There is no excuse for a system in this day and age to send invalid XML. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
Vitor |
Posted: Sun Feb 19, 2012 7:04 am Post subject: Re: Escaping < while parsing the data against XMLNSC doma |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
najmaaaa wrote: |
Need to make this as a perfect XML like below. |
The correct term is "well-formed".
najmaaaa wrote: |
Can anyone help me in solving this problem. |
You need the source system to send well formed XML; either by escaping the data or using CDATA or whatever method works in your implementation.
Failing that, you need far more code than a simple line to identify all the '<' & '>' which are not followed by their matching character but another such character & escaping the errent character. The accepted term for such activity is "parsing" and you'd be better off using a low level language like C or Java to attempt this doomed-to-failure exercise.
Tell whoever's sending you the file if it doesn't open in IE you can't process it. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|