문제
이 피드 (Snippit)는 다음과 같이 보일 필요가 있습니다.
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
이 C# 코드에 추가하여 추가 xmlns XSI Junk를 추가해야합니다.
writer.WriteStartDocument();
writer.WriteStartElement("AmazonEnvelope");
이 피드는 그것없이 거부됩니다.
올바른 솔루션이 없습니다
다른 팁
이 시도:
writer.WriteStartElement("AmazonEnvelope");
writer.WriteAttributeString(
"xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance");
writer.WriteAttributeString(
"xsi", "noNamespaceSchemaLocation", null, "amzn-envelope.xsd");
...
writer.WriteEndElement();
.NET 3.5가 옵션입니까?
XNamespace ns = "http://www.w3.org/2001/XMLSchema-instance";
string s = new XElement("AmazonEnvelope",
new XAttribute(XNamespace.Xmlns + "xsi", ns),
new XAttribute(ns + "noNamespaceSchemaLocation", "amzn-envelope.xsd")
).ToString();
또는 함께 XmlWriter
:
const string ns = "http://www.w3.org/2001/XMLSchema-instance";
writer.WriteStartDocument();
writer.WriteStartElement("AmazonEnvelope");
writer.WriteAttributeString("xmlns", "xsi", "", ns);
writer.WriteAttributeString("xsi", "noNamespaceSchemaLocation",
ns, "mzn-envelope.xsd");
writer.WriteEndDocument();
제휴하지 않습니다 StackOverflow