I have a web service that receives an xml Node and xpath and should send back the matching node. My code works fine, the only problem is when the matching node is an XmlAttribute then it throws the following exception:
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: Cannot write a node of type XmlAttribute as an element value. Use XmlAnyAttributeAttribute with an array of XmlNode or XmlAttribute to write the node as an attribute.
This is the xmlNode the server receives :
"<r xmlns=''> <a x='alpha'>aa <x>beta</x> cc</a> <b/> <a>AAA</a> </r>",
And xpath is “r/a/@x”
it returns an array of xmlNode
foreach (XmlNode matchingNode in list)
{
nodeResult[i] = matchingNode ;
}
Can anyone help me to solve this problem please?