Author |
Message
|
WBISurvivor |
Posted: Mon May 22, 2006 7:01 pm Post subject: Extract XML elements from a XML message as a String object |
|
|
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 |
|
 |
jefflowrey |
Posted: Mon May 22, 2006 7:28 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You need 'ASBITSTREAM'. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon May 22, 2006 7:48 pm Post subject: |
|
|
 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 |
|
 |
jefflowrey |
Posted: Mon May 22, 2006 7:57 pm Post subject: |
|
|
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 |
|
 |
fjb_saper |
Posted: Mon May 22, 2006 8:03 pm Post subject: |
|
|
 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 |
|
 |
WBISurvivor |
Posted: Tue May 23, 2006 11:58 am Post subject: |
|
|
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 |
|
 |
jefflowrey |
Posted: Tue May 23, 2006 12:11 pm Post subject: |
|
|
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 |
|
 |
WBISurvivor |
Posted: Wed May 24, 2006 6:47 am Post subject: |
|
|
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 |
|
 |
jefflowrey |
Posted: Wed May 24, 2006 6:54 am Post subject: |
|
|
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 |
|
 |
|