简体   繁体   English

如何创建 XML

[英]How to create XML with <![CDATA[<?xml in PL SQL

Let's suppose that I want to generate a part of the XML extracting data from a table and put this part inside the [CDATA element.假设我想生成从表中提取数据的 XML 的一部分,并将这部分放在 [CDATA 元素中。

For example, let's suppose that I generate this XML例如,假设我生成了这个 XML

select    xmlelement("TAG1",
          xmlelement("TAG2",col2),
          xmlelement("TAG3",
          xmlelement("TAG4",col4)))
from MYTABLE

where col2 and col4 are columns of MYTABLE其中 col2 和 col4 是 MYTABLE 的列

so as to get the follow XML:以获得以下XML:

<TAG1>
 <TAG2> 10 </TAG2>
 <TAG3>
  <TAG4> England </TAG4>
 </TAG3>
</TAG1>

But now let's suppose I want to get something like this:但现在让我们假设我想得到这样的东西:

<TAG1>
 <TAG2> 10 </TAG2>
 <![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <TAG3>
  <TAG4> England </TAG4>
 </TAG3> ]]>
</TAG1>

how can I do it?我该怎么做? What I mean is even in this case I want the part inside the CDATA to be created not with constant long string but alway extracting data from the table and I want this section closed after TAG3我的意思是,即使在这种情况下,我希望 CDATA 中的部分不是使用常量长字符串创建,而是始终从表中提取数据,并且我希望在 TAG3 之后关闭此部分

Let's suppose that I want to generate a part of the XML extracting data from a table and put this part inside the [CDATA element.假设我想生成从表中提取数据的 XML 的一部分,并将这部分放在 [CDATA 元素中。

For example, let's suppose that I generate this XML例如,假设我生成了这个 XML

select    xmlelement("TAG1",
          xmlelement("TAG2",col2),
          xmlelement("TAG3",
          xmlelement("TAG4",col4)))
from MYTABLE

where col2 and col4 are columns of MYTABLE其中 col2 和 col4 是 MYTABLE 的列

so as to get the follow XML:以获得以下XML:

<TAG1>
 <TAG2> 10 </TAG2>
 <TAG3>
  <TAG4> England </TAG4>
 </TAG3>
</TAG1>

But now let's suppose I want to get something like this:但现在让我们假设我想得到这样的东西:

<TAG1>
 <TAG2> 10 </TAG2>
 <![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <TAG3>
  <TAG4> England </TAG4>
 </TAG3> ]]>
</TAG1>

how can I do it?我该怎么做? What I mean is even in this case I want the part inside the CDATA to be created not with constant long string but alway extracting data from the table and I want this section closed after TAG3我的意思是,即使在这种情况下,我希望 CDATA 中的部分不是使用常量长字符串创建,而是始终从表中提取数据,并且我希望在 TAG3 之后关闭此部分

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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