Author |
Message
|
samgn123 |
Posted: Wed Nov 05, 2008 1:08 am Post subject: XML Field Lookup Using ESQL |
|
|
Newbie
Joined: 04 Nov 2008 Posts: 8
|
Hi All,
I am new to message broker . Please help me in this task, which seems to be simple but yet tricky.
I want to lookup for a particular XML Element/Attribute to check whether is present in the Input Message .
I tried treating the whole XML as String and using POSITION. But that seems to be a improper way to do so. Please help me in this regard
Thanks,
Samgn |
|
Back to top |
|
 |
Gaya3 |
Posted: Wed Nov 05, 2008 1:59 am Post subject: |
|
|
 Jedi
Joined: 12 Sep 2006 Posts: 2493 Location: Boston, US
|
you can easily do by checking that attribute/element is NULL or not
there is no need to make it as a string and do the same. _________________ Regards
Gayathri
-----------------------------------------------
Do Something Before you Die |
|
Back to top |
|
 |
kimbert |
Posted: Wed Nov 05, 2008 2:30 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
I tried treating the whole XML as String and using POSITION. But that seems to be a improper way to do so |
I would not say 'improper'. That approach is inaccurate, unmaintainable, and as far from 'best practice' as I can imagine. You should never parse any kind of message using ESQL unless your message format is trivially simple. Parsing XML using ESQL is just an awful idea.
You need to
- Set the Domain to XMLNSC on the input node
- Do what Gaya3 suggested
I strongly recommend that you get some training in how to use the product, or else work through the Samples Gallery and do some self-training. |
|
Back to top |
|
 |
samgn123 |
Posted: Wed Nov 05, 2008 9:40 pm Post subject: |
|
|
Newbie
Joined: 04 Nov 2008 Posts: 8
|
Thanks for the response. Will try to do the same. But what if I have to lookup for an element which does not have a full path attached to that, just like "Firstname" . You do not know where it is and have to lookup in the whole XML. |
|
Back to top |
|
 |
Vitor |
Posted: Thu Nov 06, 2008 2:25 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
samgn123 wrote: |
But what if I have to lookup for an element which does not have a full path attached to that, just like "Firstname" . You do not know where it is and have to lookup in the whole XML. |
All XML elements have a path, even if it's the root!
If you put the message on the XMLNSC Domain you'll get a fully parsed message tree and you can traverse it with any technique you like. Any of these will be easier to manage & maintain than trying to chop up a string. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
kimbert |
Posted: Thu Nov 06, 2008 3:06 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
You could always use the XPath query '//FirstName'. The JavaCompute node supports XPath. But before you do that, ask yourself the following questions:
- Do you really need to check the entire message? I'll bet that 'FirstName' only appears in a limited number of places in the message. There must be some definition of the input XML, possibly in a DTD or XML Schema.
- What do you want to do if 'FirstName' is in the message? If you need to change the message content in any way, you will need to parse it anyway. |
|
Back to top |
|
 |
samgn123 |
Posted: Wed Nov 19, 2008 2:21 am Post subject: |
|
|
Newbie
Joined: 04 Nov 2008 Posts: 8
|
Hi ,
Thanks for the reply. The problem is solved by using the XPATH. Now i am able to search and Element/Attribute for a corresponding value , even if no full path specified
Thanks again |
|
Back to top |
|
 |
|