Reputation: 145
How do you preserve HTML entities using HXT ?
The withSubstHTMLEntities
SystemConfig doesn't seem to change anything :
runX $ xshow $ readString [] "<doc><p> > </p></doc>"
and
runX $ xshow $ readString [withSubstHTMLEntities no] "<doc><p> > </p></doc>"
both produce
["</ source=\"\"<doc><p> > </p></doc>\"\" transfer-URI=\"string:\" transfer-Message=\"OK\" transfer-Status=\"200\"><doc><p> > </p></doc><//>"]
I have absolutely no clue as to where to look. I pretty much tried all the other option that I can pass to readDocument
or readString
Thanks
Upvotes: 3
Views: 128
Reputation: 5001
You can use writeDocumentToString
from Text.XML.HXT.Arrow.WriteDocument
. The signature is :
writeDocumentToString :: ArrowXml a => SysConfigList -> a XmlTree String
So, for instance,
f :: IO String
f = do
let arr = readString [] "<doc><p> <tag> </p></doc>" >>> writeDocumentToString []
results <- runX arr
return . head $ results
f
will return IO "<doc><p> <tag> </p></doc>"
. (which is good enough to avoid <tag>
to be parsed as a tag)
Upvotes: 1