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 attribute using Java compute node

Post new topic  Reply to topic
 Accessing attribute using Java compute node « View previous topic :: View next topic » 
Author Message
newbeeMB
PostPosted: Wed May 27, 2015 9:43 am    Post subject: Accessing attribute using Java compute node Reply with quote

Newbie

Joined: 27 Apr 2015
Posts: 7

Hi there,

I have this xml as request and i'll have to access the attribute inside the <b:Item> element and get its value using Java compute node.

Code:
<a:Order>
   <a:OrderID>AABB12</a:OrderID>
   <b:Items>
      <b:Item typeName="Computers">COM</b:Item>
      <b:Item typeName="Mobile">MOB<b:Item>
      ...
      <b:Item typeName="Clothing">CLO<b:/Item>
   <b:Items>
</a:Order>


Output:
COM
MOB
CLO



For that i do this:

Code:
MbElement items=contact admin.getMessage().getLastChild().getLastChild().getFirstElementByPath("OrderID/Items");

String com=items.getNextChild().getFirstElementByPath("typeName").getValueAsString();

String mob=items.getNextSibling().getFirstElementByPath("typeName").getValueAsString();

..


When i do this, i get only this:

Computers
Mobile
Clothing

not the values. Please assist.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed May 27, 2015 9:51 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

It's almost as if the tree structure doesn't match what your code is doing, and as if the type of an XMLNSC Attribute is different than the type of an XMLNSC element.

I wonder if a trace would show the necessary information?
Back to top
View user's profile Send private message
iibmate
PostPosted: Wed May 27, 2015 5:54 pm    Post subject: Re: Accessing attribute using Java compute node Reply with quote

Apprentice

Joined: 17 Mar 2015
Posts: 38
Location: Perth, WA

newbeeMB wrote:


String mob=items.getNextSibling().getFirstElementByPath("typeName").getValueAsString();



You are navigating typeName field

newbeeMB wrote:

When i do this, i get only this:

Computers
Mobile
Clothing

not the values. Please assist.


Obviously you will get attribute value and not element values.

To get element values, try this...

String com=items.getNextChild().getValueAsString();
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 » Accessing attribute using Java compute node
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.