How to unencode escaped XML with xQuery

前端 未结 3 459
-上瘾入骨i
-上瘾入骨i 2021-01-17 23:16

I have a variable in xQuery of type xs:string with the value of an encoded HTML snippet (the content of a twitter tweet). It looks like this:

Headline

3条回答
  •  广开言路
    2021-01-17 23:38

    Depends on which XQuery processor you are using... The easiest way is to be using a processor that has an extension that handles this for you. For instance, with Saxon and the following XML:

    <c>asdf</c>
    

    You can write an XQuery that uses the saxon:parse() function to do what you want:

    declare namespace saxon = "http://saxon.sf.net/";
    
    {
      saxon:parse(doc('test.xml')/a)
    }
    

    The result from that is:

    
      asdf
    
    

    I think most(?) XQuery processors will have an extension to do this for you. Hope that helps.

提交回复
热议问题