|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
xpath jcn |
« View previous topic :: View next topic » |
Author |
Message
|
paustin_ours |
Posted: Fri Mar 21, 2014 11:05 am Post subject: xpath jcn |
|
|
Yatiri
Joined: 19 May 2004 Posts: 667 Location: columbus,oh
|
i have an input xml that has repeating element
Code: |
<test>
<in>...
<in>...
<in>...
.
.
</test>
|
i tried
Code: |
MbElement root = message.getRootElement();
MbElement XML =root.getLastChild();
MbXPath exp = new MbXPath("test/in[2]");
XML.evaluateXPath(exp);
|
now when i do
Code: |
XML.evaluateXPath(exp).toString();
|
i do see the second entry value of in
but how can i get the value to a String like i would
if i do a getValueAsString()
Since the evaluate returns a obj, i tried casting it to a MBelement
Mb element mbe = (Mbelement) XML.evaluateXPath(exp);
thought i might get the value from that, but that errors out.
any suggestions would be of great help.
thanks. |
|
Back to top |
|
 |
paustin_ours |
Posted: Fri Mar 21, 2014 12:28 pm Post subject: |
|
|
Yatiri
Joined: 19 May 2004 Posts: 667 Location: columbus,oh
|
saw an example in the infocenter that the evaluatexpath returns an array list. I put in a list and got the value from there.
that worked.
thanks. |
|
Back to top |
|
 |
paustin_ours |
Posted: Sat Mar 22, 2014 6:43 am Post subject: |
|
|
Yatiri
Joined: 19 May 2004 Posts: 667 Location: columbus,oh
|
Well, i ran into another problem.
I build and envrionment tree
i parse the incoming message and store it in the env tree.
my env tree looks like this
Environemnt
TESTDATA
MRM
(parsed data tree)
Now when i try to reference one of the MRM fields using the evaluateXpath, it is not finding it.
Here is the code
Code: |
MbElement env_data = assembly.getGlobalEnvironment().getRootElement
();
MbXPath mbx = new MbXPath("MRM/ORDER_ITEM_NAME");
String xpathvar = env.evaluateXPath(mbx).toString();
|
String value is [] in debugger
when i do
Code: |
MbXPath mbx = new MbXPath("TESTDATA");
|
it is returning the value in TESTDATA
I have tried just about everything, have tried to to step through and get firstchild, next sibling, getname etc., to confim the tree is actually there and it is there.
Any thoughts? Pls let me know. Thanks.[/code] |
|
Back to top |
|
 |
paustin_ours |
Posted: Sat Mar 22, 2014 8:46 am Post subject: |
|
|
Yatiri
Joined: 19 May 2004 Posts: 667 Location: columbus,oh
|
MbXPath mbx = new MbXPath("MRM/ORDER_ITEM_NAME",env);
recognizes the value. For some reason, i have to specifically do that to make it know thatenv is the root element to start looking for data.
I wonder why. But atleast it is working.
thanks. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|