Suzanne, It looks like a namespace thing. Because "username" exists in the http://trade.com namespace, you need to define that in the XPath expression.
XPath expressions are not the best where it comes to handling default namespaces. If you define an extra namespace expression in soap:Envelope of xmlns:tc="http://trade.com" and then use the expression SimpleXPathAPI mysoap.xml / //tc:username you will select all the "username" nodes in the document that exist in the trade.com namespace. Cheers, Berin > > From: Suzanne Dirkers <[EMAIL PROTECTED]> > Subject: xpath expression > Date: 27/03/2003 4:54:11 > To: [email protected] > > > > > > Hi Folks, > > > I must be the least intuitive individual ever to work on trying to > work on xpath expressions. Once again it seems I have tried every which way > to use an xpath expression to try to get some information out of a file > using SimpleXPathAPI here, and wouldn't you know, a lot of things that I > *think* should work according to examples in the Xpath work, don't. > > This is my xml file: > <?xml version="1.0"?> > <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> > <login xmlns="http://trade.com"> > <username>uid:xyz</username> > <password>aaa > </password> > </login> > </soap:Body> > </soap:Envelope> > > > I found that ONLY /soap:Envelope/soap:Body would work as the context > node. I could NOT extend that path for the context node any farther than > 'Body'. > > However, I did think this should work: SimpleXPathAPI mysoap.xml > soap:Envelope/soap:Body ./login/username > The string value of the result is: > (no result) > > > Also tried:SimpleXPathAPI mysoap.xml soap:Envelope/soap:Body > ./*/username > The string value of the result is: > (no result) > > > SimpleXPathAPI mysoap.xml soap:Envelope/soap:Body .//username > The string value of the result is: > (no result) > > SimpleXPathAPI mysoap.xml soap:Envelope/soap:Body child::username > (no result) > > SimpleXPathAPI mysoap.xml soap:Envelope/soap:Body descendant::username > The string value of the result is: > (no result) > > > The ONLY!!!! thing I found that actually yielded a result was: > SimpleXPathAPI mysoap.xml soap:Envelope/soap:Body child::* > The string value of the result is: > uid:0 > xxx > > From what I can tell , although 'username' is not prefixed by anything, > which to me means it should have no problem finding it, just like any > tagname on any xml element, and in my earlier posts I talked about being > able to find 'zipcode' in another xml file which also did not have a prefix > (and zipcode was found), 'username' here seems to be box office poison. > WHY?? > > And, how do I get JUST the 'uid:0' back as a result? > > Thanks, > Suzanne > > This message was sent through MyMail http://www.mymail.com.au
