How do I convert a string to XML Dom Node?

13 ビュー (過去 30 日間)
Naum Derzhi
Naum Derzhi 2021 年 12 月 29 日
回答済み: Mann Baidi 2023 年 9 月 15 日
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?

回答 (1 件)

Mann Baidi
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!

カテゴリ

Help Center および File ExchangeStructured Data and XML Documents についてさらに検索

タグ

製品


リリース

R2017b

Translated by