我有一个XMLNode item
要附加到XMLNode targetNode
的XMLDocument docRss
XmlNode targetNode = docRss.SelectSingleNode("channel");
targetNode .AppendChild(docRss.ImportNode(item, true));
异常:对象引用未设置为对象的实例。
编辑我发现targetNode 为空,但为什么呢?如在 docRss.innerXml 中向我们展示它的存在
在此声明之前的值是:
docRss.innerXml = <?xml version=\"1.0\"?><rss version=\"2.0\"><channel><title>The federal Savings Bank News Feeds</title><link>https://www.thefederalsavingsbank.com</link><description>The federal Savings Bank News Feeds</description><language>en-us</language></channel></rss>
item.innerXml = <title>Housing market improvement helps economy</title><link>https://www.thefederalsavingsbank.com/Advice</link><description>&lt;p&gt;According to The Associated Press, a strong housing report helped improve the stock market, showing that the housing market affects more than just one industry.&lt;/p&gt;\r\n&lt;p&gt;The Dow increased by 5.22 points to close at 13,557, which marked the fourth straight day of gains, which is thought to be a result of the improving housing market.&lt;/p&gt;\r\n&lt;p&gt;Time Magazine recently reported that a recovery for the housing market is also great news for large banks. The Department of Commerce announced that new residential construction projects increased by 15 percent in September in comparison to the prior month, and they also increased by 34.8 percent compared to last year.&lt;/p&gt;\r\n&lt;p&gt;Housing starts are still down from the numbers that were seen before the recession, but the market is steadily improving every month.&lt;/p&gt;\r\n&lt;p&gt;First-time home buyers who are interested in purchasing a home might look at now as the perfect time considering the low cost of mortgages and affordable rates that are offered. Those considering buying their first home should look into FHA loans considering they offer lower interest rates.&lt;/p&gt;</description>