此为 Mathematica 7 文档,内容基于更早版本的 Wolfram 语言
查看最新文档(版本11.1)

ToCompactXML

ToCompactXML[expr]
generates an equivalent SymbolicXML expression that suppresses all the redundant namespace information for elements and attributes in expr.
ToCompactXML[expr, patt]
suppresses only namespaces that match patt.
  • To use ToCompactXML, you first need to load the XML Package using Needs["XML`"].
  • The following option can be given:
"AttributesDefaultNameSpace""NullNameSpace"controls how attribute namespaces are abbreviated
Needs["XML`"]
XML with explicit namespace information:
In[2]:=
Click for copyable input
ToCompactXML suppresses redundant namespace information for elements. Attributes in the null namespace always get compacted, regardless of the setting of "AttributesDefaultNameSpace":
In[3]:=
Click for copyable input
Out[3]=
In[4]:=
Click for copyable input
Out[4]=
Attributes in the same default namespace as the element only get compacted when "AttributesDefaultNameSpace" is "ElementNameSpace".
In[5]:=
Click for copyable input
Out[5]=
In[6]:=
Click for copyable input
Out[6]=
Attributes in other namespaces do not get compacted:
In[7]:=
Click for copyable input
Out[7]=
In[8]:=
Click for copyable input
Out[8]=
If the namespace of a tag is explicit but different from the default, attributes will not be compacted:
In[9]:=
Click for copyable input
Out[9]=
The default namespace may be inherited from containing tags:
In[10]:=
Click for copyable input
Out[10]=