matlab.io.xml.dom.DOMWriter Class
Namespace: matlab.io.xml.dom
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
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de 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)