matlab.io.xml.dom.DOMWriter class
Package: matlab.io.xml.dom
Writer that serializes an XML document
Description
Use an object of the matlab.io.xml.dom.DOMWriter
class to create a writer
that serializes an XML document.
The matlab.io.xml.dom.DOMWriter
class is a handle
class.
Class Attributes
ConstructOnLoad | true |
HandleCompatible | true |
For information on class attributes, see Class Attributes.
Creation
Description
writer = matlab.io.xml.dom.DOMWriter()
creates a
writer to serialize a matlab.io.xml.dom.Document
object. Use the Configuration property to specify
writer options.
Properties
Configuration
— writer options
matlab.io.xml.dom.WriterConfiguration
object
Writer options, specified as a matlab.io.xml.dom.WriterConfiguration
object.
Attributes:
GetAccess | public |
SetAccess | immutable |
Transient | true |
NonCopyable | true |
Data Types:
Methods
Public Methods
write |
Specify Use this method to mix non-XML text with serialized XML text. | ||||||||
writeToFile |
Specify
Use this method to serialize an XML DOM document to a file. If the file is stored at a
remote location, then
Based on the remote location,
For more information, see Work with Remote Data. Example:
| ||||||||
writeToString |
Specify
| ||||||||
setNewLine |
Specify
| ||||||||
getNewLine |
|
Examples
Write XML Document to File
Write an XML document to a file using a matlab.io.xml.dom.DOMWriter
object.
Create an XML document as a matlab.io.xml.dom.Document
object.
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);
Create a writer to serialize the XML document.
xmlFileName = "weekdays.xml";
writer = matlab.io.xml.dom.DOMWriter;
Save the XML document to a file.
writeToFile(writer,docNode,xmlFileName);
Version History
Introduced in R2021a
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 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)