How do I convert a string to XML Dom Node?
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a file, part of which contains a string representing an XML DOM node. I have this whole string in memory as a char variable. Is there a way to convert it to DOM node, without using an intermediate file?
0 comentarios
Respuestas (1)
Mann Baidi
el 15 de Sept. de 2023
Hi Naum,
I understand you would like to convert a string to XML Dom Node without converting it to a file.
I suggest you use the “parseString” function in MATLAB. For using it you will have to import “matlab.io.xml.dom.* ”. However, I would still advise you to use “xmlread” function using the file as “parseString” will not make the children nodes.
Here is an example code of parseString:
import matlab.io.xml.dom.*
s1 = "<days><day>Mon</day><day>Tue</day><day>Wed</day>";
s2 = "<day>Thu</day><day>Fri</day></days>";
xmlString = s1+s2;
doc = parseString(Parser,xmlString);
x= parseChildNodes(doc);
For more information, you can refer the documentation of the “parseString” function:
Hope this helps!
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!