matlab.io.xml.dom.DOMWriter 类
包: matlab.io.xml.dom
创建对象
说明
writer = matlab.io.xml.dom.DOMWriter()
创建一个写入器来串行化 matlab.io.xml.dom.Document
对象。请使用 Configuration 属性指定写入器选项。
属性
Configuration
— 写入器选项
matlab.io.xml.dom.WriterConfiguration
对象
写入选项,指定为 matlab.io.xml.dom.WriterConfiguration
对象。
属性:
GetAccess | public |
SetAccess | immutable |
Transient | true |
NonCopyable | true |
数据类型:
方法
公共方法
write |
将 使用此方法将非 XML 文本与串行化的 XML 文本混合在一起。 | ||||||||
writeToFile |
将 使用此方法将 XML DOM 文档串行化为文件。 如果文件存储在远程位置,则
根据远程位置,
有关详细信息,请参阅处理远程数据。 示例: | ||||||||
writeToString |
将 | ||||||||
setNewLine |
可将
| ||||||||
getNewLine |
|
示例
将 XML 文档写入文件
使用 matlab.io.xml.dom.DOMWriter
对象将 XML 文档写入文件。
将 XML 文档创建为 matlab.io.xml.dom.Document
对象。
import matlab.io.xml.dom.* docNode = Document("root_element"); docRootNode = getDocumentElement(docNode); weekdays = ["Mon" "Tue" "Wed" "Thu" "Fri"]; weekdaysElement = createElement(docNode,"weekdays"); for i=1:5 dayElement = createElement(docNode,"day"); appendChild(dayElement,createTextNode(docNode,weekdays(i))); appendChild(weekdaysElement,dayElement); end appendChild(docRootNode,weekdaysElement);
创建一个写入器来串行化该 XML 文档。
xmlFileName = "weekdays.xml";
writer = matlab.io.xml.dom.DOMWriter;
将 XML 文档保存到文件中。
writeToFile(writer,docNode,xmlFileName);
版本历史记录
在 R2021a 中推出
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)