从CDATA中提取值 [英] Extracting values from CDATA
问题描述
我正在尝试使用XSLT获取XML文件中的FIELD2和FIELD3中的值
。我可以得到CLOB_DATA的值。它返回为
一个字符串。如何提取值FIELD2和FIELD3?
提前谢谢。
<?xml version =" 1.0"编码= QUOT; UTF-8英寸standalone =" no"?>
< XML>
< FIELD1> field1< / FIELD1>
< CLOB_DATA>
<![CDATA [<?xml version =" 1.0"?>
< FIELD2> field2< / FIELD2>
< FIELD3> field3< / FIELD3>
]]>
< / CLOB_DATA>
< / XML>
I am trying to get the values in FIELD2 and FIELD3 in the XML file
below using XSLT. I can get the value of CLOB_DATA. It comes back as
an string. How can I extract the values FIELD2 and FIELD3?
Thanks in advance.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<XML>
<FIELD1>field1</FIELD1>
<CLOB_DATA>
<![CDATA[<?xml version="1.0"?>
<FIELD2>field2</FIELD2>
<FIELD3>field3</FIELD3>
]]>
</CLOB_DATA>
</XML>
推荐答案
Dana B写道:
Dana B wrote:
我试图使用XSLT获取XML文件中的FIELD2和FIELD3中的值
。我可以得到CLOB_DATA的值。它返回为
一个字符串。如何提取FIELD2和FIELD3的值?
I am trying to get the values in FIELD2 and FIELD3 in the XML file
below using XSLT. I can get the value of CLOB_DATA. It comes back as
an string. How can I extract the values FIELD2 and FIELD3?
< CLOB_DATA>
<![CDATA [<?xml version =" 1.0"? >
< FIELD2> field2< / FIELD2>
< FIELD3> field3< / FIELD3>
]]>
< / CLOB_DATA>
<CLOB_DATA>
<![CDATA[<?xml version="1.0"?>
<FIELD2>field2</FIELD2>
<FIELD3>field3</FIELD3>
]]>
</CLOB_DATA>
对于CDATA部分中的内容,您的XSLT样式表只能看到一个
字符串,没有字段或元素。所以你需要有办法解析
那个字符串作为需要扩展函数的XML,XSLT 1.0不能直接做
。
< br $> b $ b -
Martin Honnen
http://JavaScript.FAQTs.com/
你能给我看一个如何用<解析XML字符串的例子吗? br />
扩展功能?
谢谢
Dana
Can you show me an example of how I can parse the XML string with an
extension function?
Thanks
Dana
Dana B写道:
Dana B wrote:
你能告诉我一个如何用<解析XML字符串的例子吗? br />
扩展功能?
Can you show me an example of how I can parse the XML string with an
extension function?
这在很大程度上取决于您使用的XSLT处理器以及它是否支持这种扩展功能。
我可以向您展示MSXML的示例,其扩展函数是用JScript编写的
,但如果您使用的是一个
diffetrent XSLT处理器,则无法帮助您。
-
Martin Honnen
http://JavaScript.FAQTs.com/
这篇关于从CDATA中提取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!