Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 2nd, 2006, 06:09 AM
Authorized User
 
Join Date: Nov 2003
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Default Access Namespace Node using XPath

Hi,
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetData xmlns="http://.intel.com/WSS/GetData">
      <loginName>testuser</loginName>
      <password>123@wss)</password>
      <CurrentVersion>10</CurrentVersion>
      <ModTypeCode>string</ModTypeCode>
      <ParamList>string</ParamList>
      <PrufFileType>string</PrufFileType>
    </GetData>
  </soap:Body>
</soap:Envelope>

I'm trying to access the "GetData" element using the XPath "/soap:Envelope/soap:Body/GetData", but that doesn't return me anything. But if I remove the "xmlns" from "GetData", I'm able to access it. Now the client gives me the XML String in the above fashion only, I wonder how I can get access to the inner elements of GetData.

Please help.

Thanks,
Praveen
 
Old January 2nd, 2006, 06:20 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

The GetData element is in the namespace "http://.intel.com/WSS/GetData" so you need to use the XPath expression "/soap:Envelope/soap:Body/data:GetData" in which the "soap" prefix is bound to "http://schemas.xmlsoap.org/soap/envelope/" and the "data" prefix to "http://.intel.com/WSS/GetData". Of course you can use different prefixes provided you bind them to the correct namespace URI. The way you bind namespace prefixes when evaluating an XPath expression depends on the environment in which you are using XPath.

Incidentally, your question has nothing to do with namespace nodes.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
default-xpath-namespace stolte XSLT 1 March 19th, 2008 12:49 PM
XPath to get next node (sibling) jeft0nes XSLT 2 August 8th, 2007 08:30 PM
Get Node Name without namespace ramesh.kumarm XSLT 1 September 29th, 2006 02:07 AM
XPATH: Retrieve Value without namespace prefixes ramesh.kumarm XSLT 4 September 14th, 2006 03:50 AM
XPath matching with a default namespace rich_unger XSLT 5 December 4th, 2003 01:22 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.