C# code:

public void WriteISFXml(string RefNo,string TransType,string ShipmentType)

{

///初始化XML类等操作

XmlDocument xmlDoc = new XmlDocument();

///加载本地XML文件

xmlDoc.Load(sPath);

XmlNode root = xmlDoc.SelectSingleNode("ISF");

XmlElement SendersUniqueRefer = xmlDoc.CreateElement("SendersUniqueReference");

SendersUniqueRefer.InnerText = RefNo;

root.AppendChild(SendersUniqueRefer);

XmlElement SubType = xmlDoc.CreateElement("SubmissionType");

SubType.InnerText = TransType;

root.AppendChild(SubType);

XmlElement ShprTypeCode = xmlDoc.CreateElement("ShipmentTypeCode");

ShprTypeCode.InnerText = ShipmentType;

root.AppendChild(ShprTypeCode);

///保存XML文件到指定文件夹,并以特定的名字命名

xmlDoc.Save("D:\\In\\hls201004091024172300001.xml");

}

生成出來的hls201004091024172300001.xml文件用记事本打开看时,当节点ShipmentTypeCode值为空时,

(换行了)

而我现在想要当其值为空时候为(不换行)

請各位指教,有的說可以用 XmlReaderSettings ,但是不知道在哪里设置,請大家帮�

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐