extract cdata using xslt

前端 未结 5 1511
滥情空心
滥情空心 2021-01-15 20:13

Below is the xml that has CDATA section




Indiana Jones         


        
5条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-15 20:20

    First, the fact that your input XML has "CDATA" is in one sense irrelevant... the XSLT can't tell whether it's CDATA or not. What's key about your input XML is that you have escaped markup ..., and you want to turn it into a real element.

    If you know that the escaped element will always have a certain name ('film'), and you know where it occurs, you can strip it and replace it easily:

       
          
             
          
       
    

    If you don't know in advance where the escaped tags will occur and what the element names are, you could use XSLT 2.0's to find and replace them. But as Alejandro pointed out, general parsing of XML using regular expressions can get very messy. It would only be feasible if you know the markup will be simple.

提交回复
热议问题