Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
nStore data in format of XML string in SAP HANA system
In older SAP HANA versions, no XML functions were provided. With HANA 2.0, these two functions are provided- XMLEXTRACT and XMLEXTRACTVALUE for extracting XML string in SAP HANA.
Use of XMLEXTRACT
XMLEXTRACT(<XML_document>, <XPath_query> [,<NamespaceDeclarations>])
Syntax to use −
<XML_document>
Specifies an XML document of type CLOB, NCLOB, VARCHAR, or NVARCHAR.
<XPath_query>
Specifies an XPath expression of type VARCHAR or NVARCHAR.
<NamespaceDeclarations>
Specifies a namespace declaration of type VARCHAR or NVARCHAR.
Description
Returns the matching XML element. The return value is of type VARCHAR/NVARCHAR or CLOB/NCLOB depending on the type given for
If an XML element is empty (for example,
SELECT XMLEXTRACT( '<doc xmlns:ns1="http://namespace1.sap.com" xmlns:ns2="http://namespace2.sap.com"> <ns1:item><ns1:id>1</ns1:id><ns1:name>Box</ns1:name></ns1:item> <ns1:item><ns1:id>2</ns1:id><ns1:name>Jar</ns1:name></ns1:item> <ns2:item><ns2:id>3</ns2:id><ns2:name>Table</ns2:name></ns2:item> </doc>', '/doc/ns1:item[2]/ns1:name', 'xmlns:ns1="http://namespace1.sap.com" xmlns:ns2="http://namespace2.sap.com"' ) FROM DUMMY;
Use of XMLEXTRACTVALUE
XMLEXTRACTVALUE(<XML_document>, <XPath_query> [,<NamespaceDeclarations>]) <XML_document>
Specifies an XML document of type CLOB, NCLOB, VARCHAR, or NVARCHAR.
<XPath_query>
Specifies an XPath expression of type VARCHAR or NVARCHAR.
<NamespaceDeclarations>
Specifies a namespace declaration of type VARCHAR or NVARCHAR.
Description
Returns the text contents of the matching XML element. The return value is of type VARCHAR/NVARCHAR or CLOB/NCLOB depending on the type given for
If an XML element is empty (for example,
This function is only supported for single elements of child XML nodes. For example, you can use XMLEXTRACTVALUE to query the
<parent> <child> <name>Tom</name> <age>18</age> </child> </parent>
