[英]ASP.NET, XSLT, extracting values from a CDATA section
i have a small problem i have xome xml with a cdata section. 我有一个小问题,我有一个带有cdata节的xome xml。 This CDATA section contains fragments of HTMl. 该CDATA部分包含HTM1的片段。 I would like to extract some of the data inside this CDATA element. 我想提取此CDATA元素内的一些数据。 Right now i have a XSLT transformation that outputs the rest of the document as HTMl, but i need only a small part of the CDATA HTML, not the entire part - eg a my Title tag. 现在,我有一个XSLT转换,将文档的其余部分输出为HTM1,但是我只需要一小部分CDATA HTML,而不是整个部分,例如我的Title标签。 How to do this? 这个怎么做?
XSLT won't read the CDATA section as anything other than text. XSLT不会将CDATA部分读取为文本以外的任何内容。 You'll need to pre-parse your data before handing it over to XSLT. 您需要先准备好数据,然后再将其移交给XSLT。 You could use a preparsing script (written in Python, PHP, Perl, VB, whatever) and then do one of (but not limited to) the following: 您可以使用准备脚本(用Python,PHP,Perl,VB等编写),然后执行以下操作之一(但不仅限于此):
CDATA
tags and allow XSLT to handle the undesired content 删除CDATA
标记,并允许XSLT处理不需要的内容 <title>
tag to a XSLT accesible place outside the CDATA
tags 将<title>
标记移到CDATA
标记之外的XSLT可访问位置 CDATA
section, and pass the desired value as a parameter to XSLT 可能在Python中使用Beautiful Soup (
CDATA
部分中获取了所需的值,并将所需的值作为参数传递给XSLT
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.