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

XMLGetString

XMLGetString["data"]
returns the XML expression tree corresponding to a string.
XMLGetString["data", parser]
uses the pre-initialized XMLParser object to parse the string.
  • To use XMLGetString, you first need to load the XML Package using Needs["XML`"].
  • This function is similar to ImportString["data", "XML"]. However, it can take a pre-initialized XML parser.
  • The following options can be given:
"NormalizeWhitespace"Truewhether to remove leading, trailing, and multiple internal whitespace in elements
"IncludeNamespaces"Automaticwhether to explicitly include namespaces
"ValidateAgainstDTD"Automaticwhether to validate the XML against the DTD content model
"IncludeEmbeddedObjects"Nonewhether to retain comments and processing instructions
"AllowRemoteDTDAccess"Truewhether to seek DTDs on the network
"ReadDTD"Truewhether to read the DTD
"IncludeDefaultedAttributes"Falsewhether to explicitly include default attributes as defined in the DTD
"AllowUnrecognizedEntities"Automaticwhether entities undefined by the DTD are considered errors
"PreserveCDATASections"Falsewhether the distinction between CDATA sections and regular character data is maintained on import
Needs["XML`"]
XMLGetString imports a string as SymbolicXML:
In[2]:=
Click for copyable input
Out[2]=
 
Needs["XML`"]
To use XMLGetString with a pre-initialized parser, pre-initialize the parser according to a DTD at the remote URL and name that pre-initialized parser XHTMLParser:
In[2]:=
Click for copyable input
Out[2]=
Use the pre-initialized parser to validate the string on import. "Valid"->True indicates the string was validated successfully:
In[3]:=
Click for copyable input
Out[3]=