| Author |
Convert XmlNode into XmlElement
|
|
|
| Hi
I am quiet new using XML classes in C# and I have tried many things.
I am using a webservice which gaves back a XmlNode but my object, which
should use the data needs a XmlElement.
I thought his would be right:
XmlElement myXmlElement = myXmlNode as XmlElement;
But it doesnt work.
Thx
| |
| Martin Honnen 2005-08-22, 7:31 pm |
|
Luca wrote:
> I thought his would be right:
> XmlElement myXmlElement = myXmlNode as XmlElement;
You can only cast the XmlNode to an XmlElement if the NodeType is 1, it
is not possible to cast anything into an element.
So your code is the correct approach but you only get an XmlElement if
the cast is possible so you need to check
if (myXmlElement != null) {
// now use myXmlElement here
}
after your statement.
If you need more help then we need to see your XML and then you need to
explain exactly what you expect that cast to do if myXmlNode is not an
element node.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
|
|
|
|
| Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |