下面是创建xml的示例代码。
var bpsResponseXml = new XElement("BPSResponse");
bpsResponseXml.Add(new XElement("Response",
new XElement("Code", "804"),
new XElement("Text", "TagID value is not genuine")));
var outPutXml = bpsResponseXml.Value;
下面显示了当前输出xml,您可以看到字符和单词之间有空格:
<BPSResponse> <Response> <Code>804</Code> <Text>TagID value is not genuine.</Text> </Response> </BPSResponse>
而不是上面的xml,我希望如下修剪xml:
<BPSResponse><Response><Code>804</Code><Text>TagID value is not genuine.</Text></Response></BPSResponse>
请同样帮助!
下面是将解决问题的示例代码。
var bpsResponseXml = new XElement("BPSResponse");
bpsResponseXml.Add(new XElement("Response",
new XElement("Code", "804"),
new XElement("Text", "TagID value is not genuine")));
var outPutXml = bpsResponseXml.ToString(System.Xml.Linq.SaveOptions.DisableFormatting);