简体   繁体   中英

How to get element(TAG) value from XML that is stored as [XML NULLABLE] in a table in DB2

I am storing xml in a column in a table as [XML Nullable] in DB2. The table has other columns also, most of them are String. Now I have to fetch the value of an element inside the stored XML.

For Example:

  Suppose the table name is : REGEVENT Columns are: REFID (VARCHAR), APPID(VARCHAR), DATA(XML NULLABLE) 

suppose I am storing following in DATA column.

         <Employee>
            <Name>huff</Name>
         </Employee>

Now I have to get the value of Name from that XML. How to get that value.

I don't know if this can be done in 1 step. (Probably with a complicated query you can do this.)

But normally you should do this in 2 steps:

  1. Query the DB for the DATA column
  2. Parse the xml for the Name element using one of the libraries described here (DOM, SAX, ...) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM