2017-07-18 58 views

回答

0

如果你有一個包含字符串即

<?xml version="1.0" encoding="utf-8" ?> 
<!--Created with Liquid Studio 2018 (https://www.liquid-technologies.com)--> 
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
    <xs:element name="Root" type="xs:string" /> 
</xs:schema> 

然後一個元素可以包含CDATA即

<?xml version="1.0" encoding="utf-8"?> 
<!-- Created with Liquid Studio 2018 (https://www.liquid-technologies.com) --> 
<Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:\Temp\XSDFile2.xsd"> 
    Optional Text 
    <![CDATA[ 
     <someXmlData></someXmlData> 
    ]]> 
    Optional Text 
</Root> 

由於這種傳遞雖然有些解析器它可能會逃回到這一點,但兩者是有效的和等效的。

<?xml version="1.0" encoding="utf-8"?> 
<!-- Created with Liquid Studio 2018 (https://www.liquid-technologies.com) --> 
<Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="XSDFile2.xsd"> 
    Optional Text 
    &lt;someXmlData&gt;&lt;/someXmlData&gt; 
    Optional Text 
</Root>