Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2007

Tip: Looking for answers? Try searching our database.

ajax - Consuming .net web services from FireFox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Aidy - 04 Oct 2007 09:28 GMT
I couldn't find an ajax type group so I'll post here.  It's a bit OT so feel
free to suggest a better group or web forum.

I've condensed the code below to illustrate the problem I'm having.  I've
using the XPathEvaluator to query the returned XML  The issue is that the
web service adds a namespace (xmlns="http://tempuri.org/) to the root node
and I can't get my code to work with it.  The code below has two lines where
we set the text, one with the namesapce and one without.  It works without
the namespace but not with.  I think the solution is to do with the third
param of the evaluate method but I'm at a loss.  Any ideas?

var parser=new DOMParser();

//var text = "<?xml version=\"1.0\" encoding=\"utf-8\"?><ArrayOfWord
xmlns:xi=\"http://www.w3.org/2001/XMLSchema-instance\"
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
xmlns=\"http://tempuri.org/\"><Word><ID>1</ID><Value>A</Value></Word><Word><ID>2</ID><Va
lue>B</Value></Word></ArrayOfWord
>";

var text = "<?xml version=\"1.0\" encoding=\"utf-8\"?><ArrayOfWord
xmlns:xi=\"http://www.w3.org/2001/XMLSchema-instance\"
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><Word><ID>1</ID><Value>A</Value></Word><Word>
<ID>2</ID><Value>B</Value></Word></ArrayOfWord
>";

var XmlDOM=parser.parseFromString(text,"text/xml");
var oEval = new XPathEvaluator();
var oResult = oEval.evaluate ('Word/Value', XmlDOM.documentElement, null, 0,
null);
if (oResult != null)
{
   xel = oResult.iterateNext();
   while (xel)
   {
       alert (xel.textContent);
       xel = oResult.iterateNext();
   }
}
bruce barker - 04 Oct 2007 17:07 GMT
firefox follows the w3c standard for namespace support in xpath queries.
you need to supply a namespace resolver object that you pass to the
evaluate. something like:

var oResult = oEval.evaluate (
 'Word/Value',
 XmlDOM.documentElement,
 {
    normalResolver: XmlDom.createNSResolver(XmlDom.documentElement),
    lookupNamespaceURI : function(p) {
        switch(p) {
      case 'xi;:
        return "http://www.w3.org/2001/XMLSchema-instance";
           case 'xsd':
                return "http://www.w3.org/2001/XMLSchema";
           default:
                return this.normalResolver.lookupNamespaceURI(p);
        }
    }
 },
 0,
 null);

your other option is to remove the namespace specs before loading the dom.

-- bruce (sqlwork.com)

> I couldn't find an ajax type group so I'll post here.  It's a bit OT so feel
> free to suggest a better group or web forum.
[quoted text clipped - 31 lines]
>     }
> }

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.