Author |
Message
|
Frnd |
Posted: Fri Aug 05, 2011 12:14 am Post subject: Capturing part of a XML as Char to store in database |
|
|
Apprentice
Joined: 04 Jun 2007 Posts: 33
|
Hi All
i have the following requirement - Part of an incoming XML message should be inserted to database as a single column i.e, message_body. My flow has MQInput , Compute and a Error handling sub flow. Domain of MQInput used is XMLNSC. I need to store the part of the incoming XML message in a single CHAR variable so as to insert into DB. I have tried the below
SET Msgpart = ASBITSTREAM(InputRoot.XMLNSC.Msgpart[<},1208,FolderBitStream);
SET OutputRoot.Msgpart_dbupdate = CAST(Msgpart as char CCSID InputRoot.Properties.CodedCharSetId Encoding InputRoot.Properties.Encoding);
I am getting error saying that no root element found.
The input XML is of the below format
<Header>
</Header>
<MessageBody>
<A>
<ABC>F001</ABC>
<XYZ>
<XYZ1>123</XYZ1>
<XYZ2>2456></XYZ2>
</XYZ>
<DEF>
<DEF1></DEF1>
<DEF2></DEF2>
</DEF>
</A>
</MessageBody>
i am trying to capture contents of XYZ alone...Can someone pls help? |
|
Back to top |
|
 |
exerk |
Posted: Fri Aug 05, 2011 12:26 am Post subject: |
|
|
 Jedi Council
Joined: 02 Nov 2006 Posts: 6339
|
Moving this to the Broker forum...
Frnd, please take note of where you post. If you're not sure, add a comment within the post asking a moderator to move it if appropriate. Thank you. _________________ It's puzzling, I don't think I've ever seen anything quite like this before...and it's hard to soar like an eagle when you're surrounded by turkeys. |
|
Back to top |
|
 |
WGerstma |
Posted: Fri Aug 05, 2011 1:50 am Post subject: |
|
|
Acolyte
Joined: 18 Jul 2011 Posts: 55
|
|
Back to top |
|
 |
Frnd |
Posted: Fri Aug 05, 2011 3:26 am Post subject: |
|
|
Apprentice
Joined: 04 Jun 2007 Posts: 33
|
Sure exerk.will take care of it gng fwd.
hi wgerstma,
Went through the link.Thanks for sharing.So does that mean that we cannot get the content of the XYZ unless we have a root element there ?  |
|
Back to top |
|
 |
kimbert |
Posted: Fri Aug 05, 2011 4:08 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
does that mean that we cannot get the content of the XYZ unless we have a root element there ? |
Please explain what you mean in more detail. Do you have multiple document roots that you want to serialize into a single document? |
|
Back to top |
|
 |
Frnd |
Posted: Fri Aug 05, 2011 4:18 am Post subject: |
|
|
Apprentice
Joined: 04 Jun 2007 Posts: 33
|
I am looking for getting the content of XYZ into a variable.But since XYZ doesn't have a single root element, I am getting error that " No root element found" |
|
Back to top |
|
 |
kimbert |
Posted: Fri Aug 05, 2011 4:23 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Why does it matter if the the root tag 'XYZ' is included at the start and end? If you don't store the root tag then the content of the DB table will be a malformed XML document ( which is why XMLNSC refuses to write it ).
If you *really* don't want the <XYZ> at the start/end then use SUBSTRING to remove it before inserting into the DB. |
|
Back to top |
|
 |
joebuckeye |
Posted: Fri Aug 05, 2011 4:35 am Post subject: Re: Capturing part of a XML as Char to store in database |
|
|
 Partisan
Joined: 24 Aug 2007 Posts: 365 Location: Columbus, OH
|
If this is truly the entire "XML" message you are working with...
Frnd wrote: |
The input XML is of the below format
<Header>
</Header>
<MessageBody>
<A>
<ABC>F001</ABC>
<XYZ>
<XYZ1>123</XYZ1>
<XYZ2>2456></XYZ2>
</XYZ>
<DEF>
<DEF1></DEF1>
<DEF2></DEF2>
</DEF>
</A>
</MessageBody>
|
Then it is working as designed if you are getting this error as that is not valid XML. The XML tools within the broker will only work with valid XML documents.
Frnd wrote: |
I am getting error saying that no root element found. |
Your "XML" has two root elements, Header and MessageBody so therefore it is not valid.
Fix the XML and then you can use the XML tooling within the broker otherwise you will need to do string manipulation to get at your data. |
|
Back to top |
|
 |
joebuckeye |
Posted: Fri Aug 05, 2011 4:37 am Post subject: |
|
|
 Partisan
Joined: 24 Aug 2007 Posts: 365 Location: Columbus, OH
|
Not to mention that this:
Code: |
InputRoot.XMLNSC.Msgpart[<] |
does not refer to anything within the "XML" structure you posted. |
|
Back to top |
|
 |
|