今天FVF報告出了點問題,主要是因爲一個XmlNode節點的屬性值裏面有雙引號,導致格式不良好。之前我是用替換的方法來實現的,今天我換了另外一種方法:就是直接添加屬性:
string expenseNote1 = GetXmlNode(xmlRptDataDoc, "/Idr/Fund[1]/ExpenseNote");
string expenseNote2 = GetXmlNode(xmlRptDataDoc, "/Idr/Fund[2]/ExpenseNote");
XmlNode nodeItem1 = xmlDisclosureDoc.SelectSingleNode("eepdfrpt/disclosurerpt/stdreturn/item[1]");
XmlNode nodeItem2 = xmlDisclosureDoc.SelectSingleNode("eepdfrpt/disclosurerpt/stdreturn/item[2]");
//add one attribute "note" for FVF
AddAttribute(nodeItem1,"note",expenseNote1);
AddAttribute(nodeItem2, "note", expenseNote2);
private void AddAttribute(XmlNode parent, string name, string data)
{
if (parent == null || name == null || name.Length == 0) return;
string[] strName = name.Split('|');
if (data == null)
{
data = "";
}
string[] strData = data.Split('|');
for (int i = 0; i < strName.Length; i++)
{
if (parent.SelectSingleNode("@" + strName[i]) != null)
continue;
XmlAttribute attr = parent.OwnerDocument.CreateAttribute(strName[i]);
parent.Attributes.Append(attr);
if (strData[i] != null)
{
attr.InnerText = strData[i];
}
}
}