Author |
Message
|
Feysn |
Posted: Mon Aug 08, 2005 11:30 pm Post subject: Find XML tag in XML Tree |
|
|
Apprentice
Joined: 04 Jun 2004 Posts: 33 Location: Wilrijk
|
Anyone who knows how to find a Tag in a XML tree without knowing where it is, without knowing the structure of the tree.
Can it be done with a Select statement or do I really have to browse through the whole tree to find it. And how should that select statement then look like.
Remark: The XML structure mostly is with large namespaces (SAP idoc's).
Thanks A lot for the help |
|
Back to top |
|
 |
elvis_gn |
Posted: Tue Aug 09, 2005 12:28 am Post subject: |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
I don't think that is possible.
If you go for a select you will have to go to each child complex tag and check if it has the simple tag. That is a hectic job.
IF you are interested in getting the values within the tags only, then I suggest you use the BLOB, do a BLOB to String, and do a Substring to find the tag and the value between the first occurance of > and < after your tag....
Save this to the local environment and then send it to compute with MRM domain....
I dont know if this is a great idea but i guess it can work...U could wait for a better solution....which I am equally interested in... |
|
Back to top |
|
 |
Feysn |
Posted: Tue Aug 09, 2005 12:36 am Post subject: |
|
|
Apprentice
Joined: 04 Jun 2004 Posts: 33 Location: Wilrijk
|
Thanks a lot elvis_gn,
The reason I asking is because I initially wanted to store the XPATH in a database then i could browse to the element. But I in case of an xml document with large namespace it is not workable.
Code: |
SET Environment.XPATH[] =(SELECT XPATH FROM database.table )
EVAL('SET OutputRoot.Element = ' || Environment.XPATH[1 ...n ]||';');
|
If you should have smal MRM trees it is doable.
I also tried to dynamically declare Namespaces but within the eval statement you can't use DECLARE. |
|
Back to top |
|
 |
mgk |
Posted: Tue Aug 09, 2005 1:14 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
You can use DECLARE within the EVAL statement, you just have to have multiple lines of ESQL within the same EVAL statement. _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
Feysn |
Posted: Tue Aug 09, 2005 1:44 am Post subject: |
|
|
Apprentice
Joined: 04 Jun 2004 Posts: 33 Location: Wilrijk
|
mgk wrote: |
You can use DECLARE within the EVAL statement, you just have to have multiple lines of ESQL within the same EVAL statement. |
Can you give an example because I tried the following
Code: |
-- SELECT NSNAME, NS FROM Table in database
-- Loop through Namespaces
EVAL ('DECLARE ' || NSNAME || ' NAMESPACE ''' || NS || ''';');
|
And this didn't work. In the debugger It jumped back to the CREATE module line did nothing and then went allong with the following statement. |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Aug 09, 2005 3:36 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Mgk's point was that the declare is only valid within the scope of the eval statement. So you would have to include all statements that use the namespace inside the eval. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Feysn |
Posted: Tue Aug 09, 2005 3:41 am Post subject: |
|
|
Apprentice
Joined: 04 Jun 2004 Posts: 33 Location: Wilrijk
|
jefflowrey, thanks I'll try it right away |
|
Back to top |
|
 |
|