我使用一個XML文件,其內容是像下面如何在XML文件中插入值
<Invoices>
<Invoice>
<Type>[Type]</Type>
<Contact></contact>
</Invoice>
<Invoices>
,並在我的課我想,以填補在對象 我的數據來的XML ontent想在<Type>[Type]</Type>
中用obj.type 替換[type],我該如何實現這一點。只是想一個想法。
這是我的代碼:
foreach (XmlNode pnode in xmlParentNode)
{
pnode.InnerText = objInvoice.Invoice_type;
xmlRequestNode = pnode.SelectNodes("Contact");
// var app = xdoc.Root.Descendants("Appliance").SingleOrDefault(e => (string)e.Element("Name") == applianceName);
foreach (XmlNode item in xmlRequestNode)
{
if (item.Name == "ContactNumber")
{
item.InnerText = objInvoice.ContactNumber.ToString();
}
}
}
在此先感謝。
你嘗試過什麼?這不是一個複雜的任務,它將替換XMLDocument或XDocument中的某些值或節點。那麼你在哪裏遇到問題? – ryadavilli
感謝您分享您的代碼。您的XML結構中的ContactNumber在哪裏? 'xmlParentNode'是對''節點還是''的引用? XML中是否有多個''或只有一個? –
JLRishe
Seens這裏的問題已經改變。而你的代碼現在與你想要做的事沒有任何關係。 –