3
$\begingroup$

I would like to transform a an XMLObject so as to replace all the non empty attributes of the XMLElements by empty attributes.

The aim is to have a smaller structure that I could visualize with ExpressionTreePlot.

May you help me to define a appropriated code with this sample to start ?

xml = XMLObject[
  "Document"][{XMLObject["Doctype"]["DEXXMLDoc", 
   "System" -> "DEXXMLDoc.DTD"]}, 
 XMLElement[
  "DEXXMLDoc", {"name" -> "RSM-a.xml", "creator" -> "DX8", 
   "version" -> "8.0.6"}, {XMLElement[
    "designInfo", {"studyType" -> "ResponseSurface", 
     "designType" -> "CCD", "noOfRuns" -> "20", "noOfFactors" -> "3", 
     "noOfResponses" -> "2"}, {XMLElement[
      "designNotes", {}, {"This data file created by Design-Expert \
6"}]}], XMLElement[
    "blockInfo", {}, {XMLElement[
      "block", {"code" -> "0", "name" -> "Block 1"}, {}], 
     XMLElement["block", {"code" -> "1", "name" -> "Block 2"}, {}]}]
   }
  ]
 ]

Thank you for your help

$\endgroup$

1 Answer 1

2
$\begingroup$
Block[{XMLElement},
    XMLElement[x_, y : Except[{}], z_] := XMLElement[x, {}, z];
    xml
] 
XMLObject[
  "Document"][{XMLObject["Doctype"]["DEXXMLDoc", 
   "System" -> "DEXXMLDoc.DTD"]}, 
 XMLElement[
  "DEXXMLDoc", {}, {XMLElement[
    "designInfo", {}, {XMLElement[
      "designNotes", {}, {"This data file created by Design-Expert \
6"}]}], XMLElement[
    "blockInfo", {}, {XMLElement["block", {}, {}], 
     XMLElement["block", {}, {}]}]}]]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.