Two of your XML elements have problems which greatly complicates matters when trying to query them using XPath:
a) "GetResponse" - It has a namespace specified without a prefix. This puts it in the default namespace and makes it next to impossible accessing this element using simple XPath, with the exception of the follwowing expressions: /soap:Envelope/soap:Body/* /soap:Envelope/soap:Body/GetResponse[namespace-uri() = 'http:// temp.com/'] - Works only in some XPath processors. b) "results" - It has an xmlns attribute, but a blank namespace in addition to lacking a prefix. This means that this element can only be accessed using the * method: /soap:Envelope/soap:Body/*/*/results That said, if you using .NET's XML processor, you can create an XmlNamespaceManager with prefixes that map to each URI found in the XML document. These prefixes can then be used in your Xpath expression to query the document normally. On Jun 3, 3:01 am, Arjun Priyananth <[email protected]> wrote: > Hi, > > I need to extract the xml string starting from <results> and ending from > </results>. (xml is given below) > > What is the xpath i should use in .net . > > Follwoing are not working : > 1 . /Envelope/Body/GetResponse/GetResult/results > 2. > /soap:Envelope/soap:Body/GetMCodePCodeResponse/GetMCodePCodeResult/results > > <?xml version="1.0" encoding="utf-8"?> > <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xmlns:xsd="http://www.w3.org/2001/XMLSchema"> > <soap:Body> > <GetResponse xmlns="http://temp.com/"> > <GetResult> > <results xmlns=""> > <input> > <id>3c7e50bb-004160d907</id> > </input> > <output> > <list a="222" b="2222"></list> > </output> > <error></error> > </results> > </GetResult> > </GetResponse> > </soap:Body> > </soap:Envelope> > > Out put should be > > <results xmlns=""> > <input> > <id>3c7e50bb-004160d907</id> > </input> > <output> > <list a="222" b="2222"></list> > </output> > <error></error> > </results>
