Author |
Message
|
my_mqmb |
Posted: Tue Dec 22, 2015 12:07 am Post subject: How to navigate to every field value in an XML ? |
|
|
Voyager
Joined: 08 Jun 2011 Posts: 84
|
I have requirement of navigating to every XML tag's value if it and doing some operation on it , like searching for a character in it ?
How to navigate and reach every value ? What is the best suggested approach ? |
|
Back to top |
|
 |
smdavies99 |
Posted: Tue Dec 22, 2015 12:25 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
How about a Mapping node?
Not the easiest solution to code for but will (IMHO) be the best.
You will soon become an xpath expert!!!!!
But honestly, the requirement sounds rather dumb. _________________ 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 |
|
 |
maurito |
Posted: Tue Dec 22, 2015 12:28 am Post subject: Re: How to navigate to every field value in an XML ? |
|
|
Partisan
Joined: 17 Apr 2014 Posts: 358
|
my_mqmb wrote: |
I have requirement of navigating to every XML tag's value if it and doing some operation on it , like searching for a character in it ?
How to navigate and reach every value ? What is the best suggested approach ? |
There is a procedure called 'navigate' in the product documentation which does just that. You will need to modify it to adapt it to your needs. Search for CREATE PROCEDURE and look at the examples |
|
Back to top |
|
 |
timber |
Posted: Tue Dec 22, 2015 1:48 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
What is the business requirement behind this technical requirement? |
|
Back to top |
|
 |
my_mqmb |
Posted: Tue Dec 22, 2015 3:51 am Post subject: |
|
|
Voyager
Joined: 08 Jun 2011 Posts: 84
|
I need to check for any non English character in any tags value and then change the encoding accordingly . |
|
Back to top |
|
 |
maurito |
Posted: Tue Dec 22, 2015 4:38 am Post subject: |
|
|
Partisan
Joined: 17 Apr 2014 Posts: 358
|
my_mqmb wrote: |
I need to check for any non English character in any tags value and then change the encoding accordingly . |
And what is your definition of "non English character" ? |
|
Back to top |
|
 |
my_mqmb |
Posted: Tue Dec 22, 2015 5:17 am Post subject: |
|
|
Voyager
Joined: 08 Jun 2011 Posts: 84
|
maurito wrote: |
And what is your definition of "non English character" ? |
Sometimes we are getting arabic characters in the data .
I need to scan through the entire XML . I am looking for the navigate procedure too as you suggested .
I noticed in that procedure the xml tag value are always of the type 33554432
Reached Field... Type:33554432
any clue ? Can i use FIELDTYPE = 33554432 to browse only tag values while drilling down all through the XML ? |
|
Back to top |
|
 |
Vitor |
Posted: Tue Dec 22, 2015 5:35 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
my_mqmb wrote: |
any clue ? Can i use FIELDTYPE = 33554432 to browse only tag values while drilling down all through the XML ? |
You're better off using the actual constant values rather than the numeric equivalents.
The section "Field types for Path expressions" is the most relevant for you. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
maurito |
Posted: Tue Dec 22, 2015 5:40 am Post subject: |
|
|
Partisan
Joined: 17 Apr 2014 Posts: 358
|
Vitor wrote: |
my_mqmb wrote: |
any clue ? Can i use FIELDTYPE = 33554432 to browse only tag values while drilling down all through the XML ? |
You're better off using the actual constant values rather than the numeric equivalents.
The section "Field types for Path expressions" is the most relevant for you. |
or even better, understand about CCSIDs and code pages. Talk to whoever gave you the requirement and ask what is the code page of the data coming in. |
|
Back to top |
|
 |
Vitor |
Posted: Tue Dec 22, 2015 5:44 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
maurito wrote: |
or even better, understand about CCSIDs and code pages. Talk to whoever gave you the requirement and ask what it the code page of the data coming in. |
What are you doing with these Arabic characters when you find them? What are you changing them to? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
zpat |
Posted: Tue Dec 22, 2015 6:22 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
If you really want to look at every character - why not process the message as a BLOB - convert the blob to a string - use the very good string handling functions in ESQL to do whatever you want, then put it back to BLOB and use a RCD node to re-parse it as XML. _________________ Well, I don't think there is any question about it. It can only be attributable to human error. This sort of thing has cropped up before, and it has always been due to human error. |
|
Back to top |
|
 |
maurito |
Posted: Tue Dec 22, 2015 6:29 am Post subject: |
|
|
Partisan
Joined: 17 Apr 2014 Posts: 358
|
zpat wrote: |
If you really want to look at every character - why not process the message as a BLOB - convert the blob to a string - use the very good string handling functions in ESQL to do whatever you want, then put it back to BLOB and use a RCD node to re-parse it as XML. |
Because a 'character' could be 1 , 2 or 3 bytes long ( and being Arabic , probably are ), and how would the OP know ? |
|
Back to top |
|
 |
zpat |
Posted: Tue Dec 22, 2015 6:36 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
When I say character, I mean each byte.
I assume the OP knows what he is looking for? _________________ Well, I don't think there is any question about it. It can only be attributable to human error. This sort of thing has cropped up before, and it has always been due to human error. |
|
Back to top |
|
 |
maurito |
Posted: Tue Dec 22, 2015 6:43 am Post subject: |
|
|
Partisan
Joined: 17 Apr 2014 Posts: 358
|
zpat wrote: |
When I say character, I mean each byte.
I assume the OP knows what he is looking for? |
so let's suppose the input contains the euro currency sign, in UTF-8 = x'e282ac' , what are you proposing to do by looking at the bytes individually ?
x'e2' = a with a circumflex accent in ascii. |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Dec 22, 2015 12:17 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Guys, let's not get ahead of ourselves. Obviously there is a completely flawed technical requirement here that has its origin in a business requirement none of us understands.
Let the OP give us the business requirement and maybe we can offer some type of solution...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|