Main Content

matlab.io.xml.dom.writerconfiguration类

包裹:matlab.io.xml.dom

XML DOM Writer选项

描述

Use properties of amatlab.io.xml.dom.writerconfiguration对象为XML DOM作者指定选项,表示为matlab.io.xml.dom.domwriter目的。一个WriterConfiguration创建一个对象matlab.io.xml.dom.domwriter目的。使用配置property of thedomwriter对象访问WriterConfiguration目的。

matlab.io.xml.dom.writerconfigurationclass is a处理班级。

类属性

兼容
true
constructonload
true

有关类属性的信息,请参阅类属性

特性

展开全部

是否要精心打印输出XML标记,指定为trueor错误的。如果值为true,作者通过添加空格以缩进的,可读的形式产生输出来格式化输出。

属性:

GetAccess
public
setAccess
public
不可复制
true

是否将XML声明包括在输出中,指定为trueor错误的。如果值为true, the writer includes an XML declaration in the output.

属性:

GetAccess
public
setAccess
public
不可复制
true

Whether to include a Document Type Definition (DTD) in the output, specified astrueor错误的,如果值为true,并且DOM文档包含文档类型声明(DTD),作者在XML文件输出中包含DTD。

属性:

GetAccess
public
setAccess
public
不可复制
true

Whether to include a byte order mark (BOM) in the output. If the value istrue,作者在XML文件输出流的开头中包括一个BOM。

仅当作者将其写入文件时才包含一个BOM,并且输出编码是以下编码之一:

  • UTF-8

  • UTF-16

  • UTF-16LE

  • UTF-16BE

  • UCS-4

  • UCS-4LE

  • UCS-4BE

对于UTF-16和UCS-4编码,主机机器的Endian模式用于确定BOM。

属性:

GetAccess
public
setAccess
public
不可复制
true

Whether to discard default content in the output, specified astrueor错误的。如果值为true,作者使用可用信息,例如XML架构,DTD和指定标志attr节点,决定要丢弃哪些属性和内容。如果值为错误的,作者保留所有属性和内容。

属性:

GetAccess
public
setAccess
public
不可复制
true

是否要拆分CDATA部分,指定为trueor错误的。如果值为true,作者拆分包含CDATA部分终止标记的CDATA部分']]>'or unrepresentable characters in the output encoding. If the value is错误的,如果CDATA部分包含CDATA部分终止标记,则作者会引发错误']]>'或一个不可能的角色。

属性:

GetAccess
public
setAccess
public
不可复制
true

例子

全部收缩

将XML文档写入文件并格式化XML输出,以使其缩进和可读。

创建XML文档作为一个matlab.io.xml.dom.document目的。

进口matlab.io.xml.dom。*docNode = Document("root_element");docRootNode = getDocumentElement(docNode);工作日= ["Mon""Tue"“星期三”“ thu”"Fri"];WeekDayselement = CreateElement(DocNode,"weekdays");为了i = 1:5 dayElement = createElement(docNode,“天”);附录柴尔德(DayElement,createTextNode(docNode,feekdays(i)));附录柴尔德(WeegDaysElement,DayElement);结尾附录柴尔德(DocRootNode,WeegDaysElement);

创建一个作者来序列化XML文档。

xmlfileName =“ theways.xml”;writer = matlab.io.xml.dom.domwriter;

指定漂亮的格式。

writer.configuration.formatprettyprint = true;Writetofile(作者,DOCNODE,XMLFILENAME);

查看格式的文件。

type(xmlfileName);
<?xml版本=“ 1.0” encoding =“ utf-8” standalone =“ no”?>    mon  mon   tue  Day>  thu   fri   
在R2021a中引入