[英]Parse partial XML string to list of XElements
I have a partial XML string without a root element.我有一个没有根元素的部分 XML 字符串。 Eg:
例如:
<Item Id="1">some text</Item>
<Item Id="2">some other text</Item>
I need to convert this string to a list of XElements.我需要将此字符串转换为 XElements 列表。
Is there a way to do this without adding a dummy root element or splitting the string?有没有办法在不添加虚拟根元素或拆分字符串的情况下执行此操作?
Have you tried "XElement.Parse"?你试过“XElement.Parse”吗? https://docs.microsoft.com/en-us/dotnet/api/system.xml.linq.xelement.parse?view=net-5.0
https://docs.microsoft.com/en-us/dotnet/api/system.xml.linq.xelement.parse?view=net-5.0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.