I have dificulties to convert this vb code into C#
D开发者_开发技巧im billingElem As XmlElement = _
CType(xmldoc.SelectSingleNode("/order/billing"), XmlElement)
converted as
XmlElement uinelement =
(XmlElement)xmldoc.GetElementsByTagName("/Users/user/uin");
Error is Cannot implecitly convert XMLNodeList to XmlElement.
Thanks Kanta
Using VB.Net to C# Converter you get this:
XmlElement billingElem = (XmlElement)xmldoc.SelectSingleNode("/order/billing");
GetElementsByTagName can return more than one element, so it returns an XMLNodeList.
Change it to SelectSingleNode, which will only return one element and not a list.
I don't know why your converted code is calling a different method, but this will do what your original code does:
XmlElement billingElem = (XmlElement)xmldoc.SelectSingleNode("/order/billing");
Like this:
XmlElement billingElem = (XmlElement)xmldoc.SelectSingleNode("/order/billing");
精彩评论