How do I convert a string to XML Dom Node?
19 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Mann Baidi
2023-9-15
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 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!