[OpenLayers-Users] Get the value of the element of an XML File

Kalyan Kamepalli kalyan.kamepalli at gmail.com
Sat Jul 17 00:06:26 EDT 2010


Arnaud,

I want to implement exactly the same thing in my project. I made a Ajax
request same as you with onSuccess function defined in the same JS file. The
problem for me is, the function defined for onSuccess event is not
recognized and the browser showing an error message saying that the function
is not defined.

I just don't know what's wrong with that function. I have my function
defined in the same file but is not recognized on  the request execution. Do
you have any experience with this issue or have any ideas on what's went
wrong ??

The excerpt from my XML request is as follows

searchAddress: function( e ){

         var swrequest = new OpenLayers.Ajax.Request(
 "http://siasporapv01:8080/gss/native?service=locate",
 { method: "GET", onSuccess: locateServiceResponse, extractAttributes: true
}
 );
 OpenLayers.Event.stop(e);
 },

locateServiceResponse: function(){

var xmlResponse = new OpenLayers.format.XML();
 console.log( xmlResponse );

},


Any help is appreciated.


Kalyan Kampealli


On Fri, Jul 16, 2010 at 12:56 AM, Arnaud Vandecasteele <arnaud.sig at gmail.com
> wrote:

> Hi all,
>
> I'm trying to get the value of an XML file  from an external server.
> Below are the steps I do.
>
> 1/ I download this XML file with a classic Ajax request :
>
> var getVesselsXML = new OpenLayers.Ajax.Request(
> urlVessels,
>                                {
>                                  method: 'get'
>                                  ,onSuccess : drawVessels
>                                  ,extractAttributes: true
>                                }
>                        );
>
> The result of the request is :
>
> "<POSITIONS>
> <V_POS LAT="42.35675" LON="4.2338452" N="RED COUGAR" T="9" H="43"
> S="53" F="ES" M="225350000" L="32" E="5" />
> <V_POS LAT="42.532299" LON="4.35115" N="AQUAGLORY" T="7" H="217"
> S="157" F="GR" M="240119000" L="289" E="2" />...
> </POSITIONS>"
>
> 2/ In the drawVessels method I parse the result  :
>
> var XmlFormat = new OpenLayers.Format.XML();
> vessels = XmlFormat.read(XmlvesselsRequest.responseText);
>
> But I don't know how to get the attributes of a specific node. For
> example, how can i Get the LON and the LAT of each node ?
>
> I already tried somethings like that but it return me an empty string :
>
> vessel = XmlFormat.getElementsByTagNameNS(vessels,'*','V_POS');
>
> for (i in vessel){
>   var LAT = XmlFormat.getAttributeNS(vessel[i],'*','LAT');
>   console.log(LAT);
> }
>
>
>
> Thanks for your help
>
>
> Best Regards
>
> Arnaud
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100717/66bf7bf0/attachment.html


More information about the Users mailing list