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 » How to take the values of xml tag having attributes

Post new topic  Reply to topic
 How to take the values of xml tag having attributes « View previous topic :: View next topic » 
Author Message
pa1
PostPosted: Tue Mar 27, 2012 7:44 pm    Post subject: How to take the values of xml tag having attributes Reply with quote

Novice

Joined: 20 Oct 2011
Posts: 13

Hi All,

I am getting input in the below way.

<y>
<x name="city">hyderabad</x>
<x name="country">in</x>
<x name="postalcode">1919</x>
</y>

I am accessing by arrays
IF refAttrSet.x[1].(XMLNSC.Attribute)name = 'city' THEN
SET outRef.city = refAttrSet.x[1];
END IF;

Is there any way with out using array count. please help me... I am using MB7 verion


thanks in advance for ur help
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Mar 27, 2012 9:09 pm    Post subject: Re: How to take the values of xml tag having attributes Reply with quote

Grand High Poobah

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

pa1 wrote:
Hi All,

I am getting input in the below way.

<y>
<x name="city">hyderabad</x>
<x name="country">in</x>
<x name="postalcode">1919</x>
</y>

I am accessing by arrays
IF refAttrSet.x[1].(XMLNSC.Attribute)name = 'city' THEN
SET outRef.city = refAttrSet.x[1];
END IF;

Is there any way with out using array count. please help me... I am using MB7 verion


thanks in advance for ur help

Yes you can use references like (from memory)
Code:
DECLARE attname CHARACTER '';
DECLARE myref REFERENCE TO y;
DECLARE attbref REFERENCE TO y;
MOVE myref FIRSTCHILD NAME 'x';
WHILE LASTMOVE(myref) DO
  MOVE attbref TO myref;
  MOVE attbref FIRSTCHILD TYPE (XMLNSC.Attribute) NAME 'name';
  -- alternatively to this while attbref loop you could use an IF condition...
  WHILE LASTMOVE(attbref) DO
    SET attname = FIELDVALUE(attbref);
    CASE attname
       WHEN 'city'
           SET outRef.city = FIELDVALUE(myref);
       WHEN 'country'
          -- your code....
       ELSE
           -- default case
    END CASE;
    MOVE attbref NEXT SIBLING REPEAT NAME TYPE;
   END WHILE; -- attbref
  MOVE myref NEXT SIBLING REPEAT NAME TYPE;
END WHILE; -- myref

_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
mqsiuser
PostPosted: Tue Mar 27, 2012 10:22 pm    Post subject: Re: How to take the values of xml tag having attributes Reply with quote

Yatiri

Joined: 15 Apr 2008
Posts: 637
Location: Germany

fjb_saper: Your code is so nice, I enjoy(ed) reading it. Thanks!
_________________
Just use REFERENCEs
Back to top
View user's profile Send private message
kimbert
PostPosted: Wed Mar 28, 2012 1:15 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

This question crops up now and again - I've seen it before. I think it's an excellent opportunity to use the ESQL SELECT function. I would try something like this ( not tested ):
Code:

SET outRef.city = FIELDVALUE(
                      SELECT Attrs.x
                      FROM refAttrSet AS Attrs
                      WHERE Attrs.x.name='city'
                  );
Back to top
View user's profile Send private message
pa1
PostPosted: Fri Mar 30, 2012 3:25 am    Post subject: Reply with quote

Novice

Joined: 20 Oct 2011
Posts: 13

I have tried the above way but Its not working. and I have tried like this also
its not working please help

SET outRef.city =
SELECT Attrs.x
FROM refAttrSet AS Attrs
WHERE Attrs.x.(XMLNSC.Attribute)name='city';
Back to top
View user's profile Send private message
kimbert
PostPosted: Fri Mar 30, 2012 3:44 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
I have tried the above way but Its not working.
'Not working' does not help me ( or anybody else ) to help you. Either
a) tell us what actually happened, or
b) take some steps to diagnose the problem yourself. I recommend a Trace node and a user trace.
Back to top
View user's profile Send private message
mqsiuser
PostPosted: Fri Mar 30, 2012 4:54 am    Post subject: Reply with quote

Yatiri

Joined: 15 Apr 2008
Posts: 637
Location: Germany

try "SELECT ITEM" (or "outRef.city[]")

Probably you need "THE(SELECT ITEM ..."
_________________
Just use REFERENCEs
Back to top
View user's profile Send private message
kimbert
PostPosted: Fri Mar 30, 2012 6:25 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

ITEM and THE could be useful. Not sure that changing 'city' to 'city[]' will help pa1 - I think he's expecting a single (scalar ) result.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » How to take the values of xml tag having attributes
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.