Tag Info

New answers tagged


jSoupLink can be used as a workaround, like this: << jSoupLink` html2text[html_] := First@jSoupLink`ParseHTMLFragment[ "<div id=\"container\">" <> html <> "</div>", "#container", "text" ] html2text["a<span>b</span>c"] (* Out: abc *) html2text["a<foo>b</foo>c"] (* Out: abc *)


One can import raw text and use this example to remove HTML tags StringReplace[ #, "<" ~~ Except[">"] .. ~~ ">" -> ""] &@ ImportString["a<bar>b</bar>c", {"HTML", "Source"}] (* "abc" *)


I don't know what causes the issue (which looks like a bug to me), but I generally find the best way to deal with exerting control over Import not doing quit the right thing with HTML is to use the "XMLObject" element and use ordinary Mathematica functions on it, like so: In[1]:= ImportString@ ExportString[ ...

Top 50 recent answers are included