I want filter information from a .xml file, from elements that look like this:
XMLElement["div", {"class" -> "art_title linkable"},
{XMLElement["a", {"shape" -> "rect", "class" -> "ref nowrap", "href" -> "XXXX"},
{"name"} ]}]
I use the following code to filter out the text from the a element:
Cases[data,
XMLElement[
"div", {"class" -> "art_title linkable"}, {XMLElement[
"a", {___}, {papername_}]}] :> {papername}, {0, Infinity}];
(* {{"name"}} *)
But this does not work if the content of the a element is more complicated:
XMLElement["div", {"class" -> "art_title linkable"},
{XMLElement["a", {"shape" -> "rect", "class" -> "ref nowrap", "href" -> "XXXX"},
{XMLElement["b", {}, {"namepart1"}], "namepart2"} ]}]
... which gives the result {}
.
How can I extract just the text "namepart1namepart2
in this second case?
Alternatives
, e.g.XMLElement["a"|"b", _, {papername_}]
$\endgroup$