ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Accessing xml elements

Post new topic  Reply to topic Goto page 1, 2  Next
 Accessing xml elements « View previous topic :: View next topic » 
Author Message
brokerdevel
PostPosted: Fri May 28, 2010 10:42 am    Post subject: Accessing xml elements Reply with quote

Newbie

Joined: 28 May 2010
Posts: 6

Hiya,
I am having trouble accessing certain elements in a simple xml message. Coudl some pls help.
here is the tree.
<Message>
<A>
<B>
<AdditionalFlds>
<Field name="f1">abc</Field>
<Field name="f2">def</Field>
<AdditionalFlds>
</Message>

I am trying to access f1 as follows without any luck

SET ret = OutputRoot.XMLNSC.Message.(XMLNSC.Value)f1
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri May 28, 2010 11:23 am    Post subject: Re: Accessing xml elements Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

brokerdevel wrote:
I am trying to access f1 as follows without any luck

SET ret = OutputRoot.XMLNSC.Message.(XMLNSC.Value)f1


Did you even look at the ESQL manual? Or your message? Or an XML manual?

Looking at the message, I'd try:

Code:
SET ret=InputRoot.XMLNSC.Message.AdditionalFlds.Field[1].(XMLNSC.Attribute).name


Untried, untested and a user trace with a Trace node would have helped you immensely.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
brokerdevel
PostPosted: Fri May 28, 2010 11:50 am    Post subject: Reply with quote

Newbie

Joined: 28 May 2010
Posts: 6

Thanks Vit.
I tried.
SET ret=InputRoot.XMLNSC.Message.AdditionalFlds.Field[1].(XMLNSC.Attribute)name

But it returns 'f1'. I want to get the value of the field that is 'abc'
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri May 28, 2010 11:58 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

brokerdevel wrote:
But it returns 'f1'. I want to get the value of the field that is 'abc'


Well you said you wanted "f1" in your original post!

Have a little experiment and see if you can merger my corrections with your original attempt & get the value you're looking for. It's really not that hard.

My advice on tracing holds.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
napier
PostPosted: Fri May 28, 2010 11:58 am    Post subject: Reply with quote

Apprentice

Joined: 09 Oct 2007
Posts: 48
Location: USA

Did you ever look in the info centre?
First read the documentation

http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r1m0/topic/com.ibm.etools.mft.doc/ac67241_.htm?resultof=%22%61%74%74%72%69%62%75%74%65%22%20%22%61%74%74%72%69%62%75%74%22%20
Back to top
View user's profile Send private message
brokerdevel
PostPosted: Tue Jun 01, 2010 6:03 am    Post subject: Reply with quote

Newbie

Joined: 28 May 2010
Posts: 6

Sorry guys, I am unable to retrive that element.
I tried content but then should I pass value to it?
SET ret=InputRoot.XMLNSC.Message.AdditionalFlds.Field[1].(XMLNSC.content)name ?

I did try lot of experimentation but no luck. I am new to XML level access. Can someone pls help.
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Jun 01, 2010 7:22 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

brokerdevel wrote:
I did try lot of experimentation but no luck.


Post all your experiments and their results. There's no point us suggesting something that's already failed to give the results you need.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
brokerdevel
PostPosted: Tue Jun 01, 2010 7:30 am    Post subject: Reply with quote

Newbie

Joined: 28 May 2010
Posts: 6

Vitor,
Here are all those I tried...
SET ret=InputRoot.XMLNSC.Message.AdditionalFlds.Field[1].(XMLNSC.Attribute)value
SET ret=InputRoot.XMLNSC.Message.AdditionalFlds.Field[1].(XMLNSC.Field)value
SET ret=FIELDVALUE(InputRoot.XMLNSC.Message.AdditionalFlds.Field[1].(XMLNSC.Attribute)f1
SET ret=FIELDVALUE(InputRoot.XMLNSC.Message.AdditionalFlds.Field[1].(XMLNSC.Field)f1

All the above returns null. The following actually returned the field name 'f1'
SET ret=InputRoot.XMLNSC.Message.AdditionalFlds.Field[1].(XMLNSC.Attribute)name
So element access path seems to be correct. but the value access is having problem
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Jun 01, 2010 8:08 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

brokerdevel wrote:
So element access path seems to be correct. but the value access is having problem


No it's not - you're having a problem reading your own XML. There's no element called "value" in the XML so of course you don't get a result. No matter how many combinations of descriptor you use.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Jun 01, 2010 8:10 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

brokerdevel wrote:
Vitor,
Here are all those I tried...
SET ret=InputRoot.XMLNSC.Message.AdditionalFlds.Field[1].(XMLNSC.Attribute)value
SET ret=InputRoot.XMLNSC.Message.AdditionalFlds.Field[1].(XMLNSC.Field)value
SET ret=FIELDVALUE(InputRoot.XMLNSC.Message.AdditionalFlds.Field[1].(XMLNSC.Attribute)f1
SET ret=FIELDVALUE(InputRoot.XMLNSC.Message.AdditionalFlds.Field[1].(XMLNSC.Field)f1

All the above returns null. The following actually returned the field name 'f1'
SET ret=InputRoot.XMLNSC.Message.AdditionalFlds.Field[1].(XMLNSC.Attribute)name
So element access path seems to be correct. but the value access is having problem

The value access might have a problem because VALUE is a reserved ESQL word.
Try putting "value" (with the quotes). If double quotes don't work try single quotes. This should solve it.
Code:
SET ret=InputRoot.XMLNSC.Message.AdditionalFlds.Field[1].(XMLNSC.Attribute)"value"

_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
brokerdevel
PostPosted: Tue Jun 01, 2010 8:19 am    Post subject: Reply with quote

Newbie

Joined: 28 May 2010
Posts: 6

Vitor,
no, there is no element called 'value'. I am using it as verb to retrive the value of that element. (i saw you using 'name' to retrive the name so ..)
Here is the message tree...
<Message>
<AdditionalFlds>
<Field name="f1">abc</Field>
<Field name="f2">def</Field>
<AdditionalFlds>
</Message>

I want to retrive value of 'f1' that is 'abc'. the message tree is complete and has proper values. I confirmed it using visual debugger.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Jun 01, 2010 8:27 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

OOPS...
To retrieve abc try:
Code:
SET ret=InputRoot.XMLNSC.Message.AdditionalFlds.Field[1];

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Vitor
PostPosted: Tue Jun 01, 2010 8:42 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

brokerdevel wrote:
no, there is no element called 'value'. I am using it as verb to retrive the value of that element. (i saw you using 'name' to retrive the name so ..)


No I didn't - the attribute in your document is called "name"

Try looking at the document then try reading the ESQL manual!!
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
brokerdevel
PostPosted: Tue Jun 01, 2010 8:52 am    Post subject: Reply with quote

Newbie

Joined: 28 May 2010
Posts: 6

Thanks a lot fjb_saper. it worked.
Vitor, yeah i agree, i need a lot of learning to do on ESQL XML.
Back to top
View user's profile Send private message
fatherjack
PostPosted: Tue Jun 01, 2010 9:13 am    Post subject: Reply with quote

Knight

Joined: 14 Apr 2010
Posts: 522
Location: Craggy Island

fjb_saper wrote:
OOPS...
To retrieve abc try:
Code:
SET ret=InputRoot.XMLNSC.Message.AdditionalFlds.Field[1];

Have fun


Simple but effective. Although I did kinda think the OP was trying to do something marginally more complex like trying to retrieve the value of the element 'Field' whose attribute 'name' had a value of 'f1', rather than just get the first element, knowing full well that this matched his criteria.

An even simpler solution would be

Code:
SET ret = 'abc';

_________________
Never let the facts get in the way of a good theory.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Accessing xml elements
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.