xml()

Read(2214) Label: xml string, table sequence, parse,

Description:

Parse a string/a table sequence in an XML format.

Syntax:

xml(x,s)

Note:

If parameter x is an XML string, the function parses it as multilevel records or a table sequence; if x is a table sequence, the function parses it into an XML string.

Parameter:

x

An XML string/a table sequence.

s

The to-be-retrieved level; use the slash / as the separator if there are multiple to-be-retrieved levels; retrieve data from the root if it is absent..

Option:

@s

The options enables parsing an XML string in the format of K F=v F=v …>D</K> into records made up of fields K,F,… Three situations: If K’s value is D and D is multilevel XML data, the parsing result is a record sequence; if <K …./K>, D is parsed into null; if <K…></K>, D is parsed into an empty string

@b

Won’t convert data type automatically during parsing, but generate string values for all data.

Return value:

Table sequence/XML string/Multilevel records

Example:

 

A

 

1

=demo.query("select EID,NAME,SURNAME from EMPLOYEE")

2

=xml(A1)

Return an XML string.

3

<xml>

<row> <DEPTID>1</DEPTID> <DEPTNAME>sale</DEPTNAME> <FATHER>12</FATHER>

</row> <row> <DEPTID>10</DEPTID> <DEPTNAME>create</DEPTNAME> <FATHER>12</FATHER>

</row>

</xml>

 

4

=xml(A3)

Parse A3 as multilevel records.

Expand level 1 as follows:

Expand level 2 as follows:

5

<xml>

<row category="A">

<DEPTID>1</DEPTID>

<DEPTNAME>sale</DEPTNAME>

<FATHER>12</FATHER>

</row>

<row category="B">

<DEPTID>10</DEPTID>

<DEPTNAME>create</DEPTNAME>

<FATHER>12</FATHER>

</row>

</xml>

 

6

=xml@s(A5)

Parse xml string as multilevel records:

Expand the first level:

7

=xml(A3,"xml/row")

Retrieve data under row level and return it as a table sequence:

 

When @b option works:

 

A

 

1

<customer> 

 <code>01</code>

</customer>

 

2

=xml(A1)

Result: 

3

=xml@b(A1)

Result: