简体   繁体   English

如何在 CDATA 中包含 XML

[英]How to include XML in a CDATA

I need to include a full XML document inside a text field in other XML document我需要在其他 XML 文档的文本字段中包含一个完整的 XML 文档

For example例如

<mytexttag>
   <![CDATA[    
      here the xml document starting with <?xml version="1.0"
   ]]>     
</mytexttag>

I must use a fixed XSD and I can not adapt it.我必须使用固定的 XSD,我无法适应它。

I have read that CDATA is still part of the document and it means that the data in between these strings includes data that could be interpreted as XML markup, but should not be.我已经读到CDATA 仍然是文档的一部分,这意味着这些字符串之间的数据包括可以解释为 XML 标记的数据,但不应该被解释为 XML 标记。

But i don't know if I can bypass the restrictions.但是不知道能不能绕过限制。 Currently, if I include a complete XML, I have parsing errors目前,如果我包含完整的 XML,则会出现解析错误

This could be a real example这可能是一个真实的例子

<?xml version="1.0" encoding="UTF-8"?>
<mytexttag>
    <![CDATA[ <n1:ClientInvoiceExtension xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:n1="http://www.myclient.es/facturae/ClientInvoiceExtension/v1.0" xsi:schemaLocation="http://www.myclient.es/facturae/ClientInvoiceExtension/v1.0/ClientInvoiceExtension_v1_0.xsd"><Version>1.0</Version><LineExtension><InvoiceFamily>ejempló con carañññ</InvoiceFamily><ContractCode>el code</ContractCode><PurchaseRequestCode>String</PurchaseRequestCode><DerivationCode>String</DerivationCode>ContractFileCode>String</ContractFileCode><Patient><IPF>PASAPORTE</IPF><PatientId>String</PatientId><FullName>String</FullName></Patient><Process><Contingency>String</Contingency><Year>0</Year><Province>String</Province><Number>String</Number></Process><MazCenterId>String</MazCenterId><MazCenterProvince>String</MazCenterProvince><Diagnostic>String</Diagnostic><Medical>String</Medical><RecipeNumber>String</RecipeNumber><MazEmployeeFullName>String</MazEmployeeFullName>       <HealthcareDeliveryCode>String</HealthcareDeliveryCode> </LineExtension></n1:MazInvoiceExtension>]]>     
</mytexttag>

When a insert special characters like 'á ó ñ' my xml editor says it is invalid xml当插入像 'áóñ' 这样的特殊字符时,我的 xml 编辑器说它是无效的 xml

I can consider encode in base64, but I have a size restriction in that field and would rather not increase the size我可以考虑在 base64 中编码,但我在该领域有大小限制,宁愿不增加大小

问题是您的 XML 包含未以 UTF-8 格式编码的字符...

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

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