Author |
Message
|
ggriffith |
Posted: Wed Jan 14, 2009 4:34 am Post subject: How do I reference this |
|
|
 Acolyte
Joined: 17 Oct 2007 Posts: 67
|
Can anybody suggest some ESQL to access only the xx value in the following structure
<a><b>xx<c>another value</c></b></a>
If this is easy I'll be suitably embarrassed  |
|
Back to top |
|
 |
Vitor |
Posted: Wed Jan 14, 2009 4:42 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Utterly untested but
Code: |
InputRoot.XMLNS.a.b |
would be my first guess
I suspect I'm missing the point of your question because that answer is so obvious it hurts....
[edit] You might need a FIELDVALUE in there _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
kimbert |
Posted: Wed Jan 14, 2009 4:54 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Assuming that you quoted the correct XML, then it looks like this:
Code: |
<a>
<b>
xx
<c>another value</c>
</b>
</a>
|
So, as Vitor says, 'xx' is the entire text content of tag b.
I did wonder whether you meant to quote this XML instead:
Code: |
<a>
<b>
xx
<c/>
another value
</b>
</a>
|
...which would be a little less easy to access. |
|
Back to top |
|
 |
ggriffith |
Posted: Wed Jan 14, 2009 4:54 am Post subject: |
|
|
 Acolyte
Joined: 17 Oct 2007 Posts: 67
|
And I think I must be missing a brain
I too thought this would be easy, but
SET yyy = ....a.b
results in
<c>another value</c>
and using FIELDVALUE results in NULL |
|
Back to top |
|
 |
Vitor |
Posted: Wed Jan 14, 2009 4:58 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
I think you might be missing a tag rather than a brain!
Do a trace and see how that is being parsed. It looks like the <c> tag is being ignored and taken as part of the value of <b> for reasons not entirely clear.
Though I suspect the real XML is a bit more complex than a.b.c! _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Jan 14, 2009 5:03 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Vitor wrote: |
Utterly untested but
Code: |
InputRoot.XMLNS.a.b |
would be my first guess |
You forgot the C. At the end of XMLNS, that is. |
|
Back to top |
|
 |
ggriffith |
Posted: Wed Jan 14, 2009 5:04 am Post subject: |
|
|
 Acolyte
Joined: 17 Oct 2007 Posts: 67
|
<N65>
<SYCON>
<ENTITY_ID>000000K7200000010036</ENTITY_ID>
<PROCESS>N01<ENTITY_ID>000000K7200000004479</ENTITY_ID>
</PROCESS>
<PROCESS>N10<ENTITY_ID>000000K7200000010035</ENTITY_ID>
</PROCESS>
<PROCESS>N51<ENTITY_ID>000000K7200000009988</ENTITY_ID>
</PROCESS>
</SYCON>
</N65>
I need to access the N01, N10 and N51.
I'm going to repeat my tests, just in case I'm a banana |
|
Back to top |
|
 |
Vitor |
Posted: Wed Jan 14, 2009 5:08 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
ggriffith wrote: |
I'm going to repeat my tests, just in case I'm a banana |
Include a trace, just to be sure your interpretation of the structure matches the software's  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Vitor |
Posted: Wed Jan 14, 2009 5:10 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
mqjeff wrote: |
You forgot the C. At the end of XMLNS, that is. |
I did say untested. And better to find the problem than use a faster parser that simply finds the problem quicker. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
kimbert |
Posted: Wed Jan 14, 2009 5:46 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
I recommend
Code: |
SET myTarget = FIELDVALUE(InputRoot.XMLNSC.N65.SYCON.PROCESS);
|
FIELDVALUE really is recommended here, because you are attempting to get the text value of the PROCESS tag, not the subtree under PROCESS ( which also exists ).
And, as usual, please use XMLNSC unless you understand very clearly why you have chosen not to. |
|
Back to top |
|
 |
ggriffith |
Posted: Wed Jan 14, 2009 6:37 am Post subject: |
|
|
 Acolyte
Joined: 17 Oct 2007 Posts: 67
|
Already tried the FIELDVALUE suggestion and ended up with NULL, but tried it again, and here's the trace, it's still NULL
Node 'a.Compute': Executing statement ''SET OutputRoot.XMLNSC.RFCLOOP.ZNX_BAPI_LAUNCH_FI_PLUS[p].EXTENSION1[x].item.FIELD2 = FIELDVALUE(iRef.N65[i].SYCON[k].PROCESS[m]);'' at ('.a_Compute.Main', '4075.10').
Node 'a.Compute': Evaluating expression ''i'' at ('.a_Compute.Main', '4075.122'). This resolved to ''i''. The result was ''1''.
Node 'a.Compute': Evaluating expression ''k'' at ('.a_Compute.Main', '4075.131'). This resolved to ''k''. The result was ''1''.
Node 'a.Compute': Evaluating expression ''m'' at ('.a_Compute.Main', '4075.142'). This resolved to ''m''. The result was ''3''.
Node 'a.Compute': Finished evaluating expression ''FIELDVALUE(iRef.N65[i].SYCON[k].PROCESS[m])'' at ('.a_Compute.Main', '4075.102'). The result was ''NULL''. |
|
Back to top |
|
 |
ggriffith |
Posted: Wed Jan 14, 2009 6:48 am Post subject: |
|
|
 Acolyte
Joined: 17 Oct 2007 Posts: 67
|
Nobody told me about checking the 'Retain Mixed Content' checkbox on the Parser Options of the input node. If you don't, you lose all the data I've been trying to read , hence the NULL values I've been getting
I now get
<FIELD2>N51. </FIELD2>
Anybody got any suggestions as to where the dot and extra spaces are coming from. |
|
Back to top |
|
 |
Vitor |
Posted: Wed Jan 14, 2009 6:55 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
ggriffith wrote: |
Nobody told me about checking the 'Retain Mixed Content' checkbox on the Parser Options of the input node. If you don't, you lose all the data I've been trying to read , hence the NULL values I've been getting |
Yes, that's right. Someone with a particular sense of humour could be tempted to point out you'd have been fine if you'd used XMLNS.....
ggriffith wrote: |
Anybody got any suggestions as to where the dot and extra spaces are coming from. |
Not a clue. FIELD2 isn't previously defined in the ESQL by something else is it? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Jan 14, 2009 7:04 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Strange manglement of <CR><LF>?
Are you *positive* that the "." and the space don't exist in the input message? |
|
Back to top |
|
 |
Vitor |
Posted: Wed Jan 14, 2009 7:07 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
mqjeff wrote: |
Are you *positive* that the "." and the space don't exist in the input message? |
And did not exist as strange, wayward, undisplayed, unescaped hex in the original message? Where "." and space are the broker's attempt to mangle them into a form that parses? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|