Tag Info

New answers tagged

2

I'm still not sure what you want. I think it is this, but it does not reproduce the tree you have in the question for the Except["YO"] case. contractElement[xml_, tagpat_] := Block[{XMLElement}, XMLElement[tagpat, _, data_] /; FreeQ[data, XMLElement] := Sequence[]; XMLElement[tagpat, _, data_] := Sequence @@ data; xml ]; ...


0

Bendesarts: Here is a quick example: xo = ImportString["<doc><article><title style='remove'>This is an example</title><body><p ats='remove'>removea ttributes</p></body></article></doc>", "XML"]; xo = xo //. XMLElement[e_, a_, v_] -> XMLElement[e, Sequence[], v] ; xo //. XMLElement[e_, ...


1

Code outline: ClearAll[XMLNote]; (*modified, only act on target tags*) XMLNote[ XMLElement[tag : "section" | "TextHeading", attributes_, data_], m_Integer ] := ... (*new, for other tags pass down XML elements*) XMLNote[XMLElement[_, attributes_, data : {__XMLElement}], m_Integer] := Sequence @@ (XMLNote[#1, m + 30] &) /@ data; ...



Top 50 recent answers are included