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 » Extract XML elements from a XML message as a String object

Post new topic  Reply to topic
 Extract XML elements from a XML message as a String object « View previous topic :: View next topic » 
Author Message
WBISurvivor
PostPosted: Mon May 22, 2006 7:01 pm    Post subject: Extract XML elements from a XML message as a String object Reply with quote

Novice

Joined: 22 May 2006
Posts: 17

I need to extract XML element from an xml message as a string. I'm totally new to WBI and struggling to figure this out. I have an XML message like

<Root>
<Group>
<Element1>
<Ele1-Child1>name1</Ele1-Child1>
<Ele1-Child2>name2</Ele1-Child2>
</Element1>
<Element2> .... </Element2>
</Group>
<Group>
<Element1> ..... </Element1>
<Element2> ..... </Element2>
</Group>
</Root>


I need to extract <Element1> and its content as a string.
I have a Java Compute node where I need to create a string
String s = "<Element1><Ele1-Child1>name1</Ele1-Child1><Ele1-Child2>name2</Ele1-Child2></Element1>";

Any help is really appreciated. Thanks in advance.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Mon May 22, 2006 7:28 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

You need 'ASBITSTREAM'.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon May 22, 2006 7:48 pm    Post subject: Reply with quote

Grand High Poobah

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

May I suggest a different approach?
Just move the tags as reference and the children will move with them...

Think about it
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
jefflowrey
PostPosted: Mon May 22, 2006 7:57 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

How will that turn a message tree into a string?
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon May 22, 2006 8:03 pm    Post subject: Reply with quote

Grand High Poobah

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

Well from what I can see he is moving a 'node' from place a to place b.
Now if he wants to coat this as a CDATA he will need to use ASBITSTREAM but this may still allow him to take advantage of the reference.

Sorry I did not take into consideration that the target of his java method might not be some node. My mistake.
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
WBISurvivor
PostPosted: Tue May 23, 2006 11:58 am    Post subject: Reply with quote

Novice

Joined: 22 May 2006
Posts: 17

jefflowrey wrote:
You need 'ASBITSTREAM'.


Thanks for the reply.
Is there a way to do this in Java without having to use ESQL?
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue May 23, 2006 12:11 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

You can use MBSQLStatement to call ASBITSTREAM from Java.

Or you can experiment with the toBitstream method on MBElement. It might not work on anything other than the root element, though.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
WBISurvivor
PostPosted: Wed May 24, 2006 6:47 am    Post subject: Reply with quote

Novice

Joined: 22 May 2006
Posts: 17

jefflowrey wrote:
You can use MBSQLStatement to call ASBITSTREAM from Java.

Or you can experiment with the toBitstream method on MBElement. It might not work on anything other than the root element, though.


When i try
MbElement.toBitstream(null,null,null,0,0,0) it fails. Not sure what am I doing wrong here.

The MbElement that I am trying to convert to the bitstream has a structure like this

<Name>
<first Name/>
<last name/>
<personal>
<subele1/>
<subele2/>
</personal>
</Name>
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed May 24, 2006 6:54 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

You probably need to pass valid parameters to toBitstream. The Info Center describes the parameters to this call in the reference section on writing Java plug-in nodes. It's the same API in Java Compute Nodes.

Also, it might not work on anything other than the root element.
_________________
I am *not* the model of the modern major general.
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 » Extract XML elements from a XML message as a String object
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.