添加空间名称时,我无法生成 xml 字符串。这就是我想生成我的xml的方式
xml 示例:
<Feedback xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Record>
<ID>2FAC636E-F96C-4465-9272-760BAF73C0DF</QRCodeID>
<SubID>10B5236C-47FD-468D-B88D-D789CA0C663A</SubmissionID>
<UserID>1</UserID>
<Page>1</Page>
</Record>
<Record>
<ID>219C462B-B874-4408-AFBA-CA727922D50F</QRCodeID>
<SubID>10B5236C-47FD-468D-B88D-D789CA0C663A</SubmissionID>
<UserID>1</UserID>
<Page>2</Page>
</Record>
</Feedback>
我的代码现在的样子:
XDocument xdoc = new XDocument(
new XElement("Feedback xmlns:i='http://www.w3.org/2001/XMLSchema-instance'",
new XElement("Record",
new XElement("ID", idGuid),
new XElement("SubID", subGuid),
new XElement("UserID", 2),
new XElement("Page", pages)
)
)
);
当我运行它在这里抛出一个错误"Feedback xmlns:i='http://www.w3.org/2001/XMLSchema-instance'"
,它不喜欢字符''