费尔南多
我遇到过一个类似的情况,在我们的遗留系统(universe)中,它没有真正的xml解析器,而是通过原始字符串匹配工作的自制系统。我们找到的解决方案是在将要传输到系统的类中实现IXMLSerializable,并且在向XmlWriter写入时,我们可以控制添加哪些命名空间。下面是其中一个实现的示例。
/// <summary>
/// Serialize the state to XML
/// </summary>
/// <param name="writer">The writer to write the state</param>
public void WriteXml(XmlWriter writer)
{
writer.WriteElementString("TERMINATION_STATUS", Status);
writer.WriteElementString("TRANS_SEQ_NUM", Sequence.ToString());
writer.WriteElementString("INTRN_SEQ_NUM", Id.ToString());
writer.WriteElementString("CMRCL_FLAG", IsCommercialCard.ToString());
writer.WriteElementString("AUTH_CODE", Authorization);
writer.WriteElementString("CMRCL_TYPE", CommericalFlag.ToString());
writer.WriteElementString("RESULT_CODE", ResultCode.ToString());
writer.WriteElementString("TROUTD", RoutingId.ToString());
writer.WriteElementString("RESPONSE_TEXT", Message);
writer.WriteElementString("REFERENCE", ProcessorReferenceCode);
writer.WriteElementString("PAYMENT_MEDIA", PaymentMedia);
writer.WriteElementString("RESULT", Result.ToString().ToUpper());
if (Error != null)
{
writer.WriteStartElement("ERROR");
writer.WriteElementString("ERROR_CODE", Error.Code);
writer.WriteElementString("ERROR_DESCRIPTION", Error.Description);
writer.WriteEndElement();
}
}
再说一次,因为这是一个习惯的情景,我没有帮助,但它是很容易尝试。