Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Ajax Programming

manage xml object


ok, here is my problem, i'm reciving 2 xml files and i want to know
which one is. the files are some like this

<computers name='catalog'>
  <nodes ....../>
</computers>

<users name='list'>
  <nodes ...>
</users>

so, i want to know how to get the name of the root element (computers
or users) i've tried with:

responseXML.getElementsById('computers ')
responseXML.getElementsById('computers ')[0].firstChild.data
responseXML.getElementsByTagName('computers')

but i can't get the data.

thank you.

var xmlDoc = myXMLHttp.responseXML.documentElement;

var foo = xmlDoc.getElementsByTagName("computers");
var bar = null;
if(foo.length==1)bar = foo[0];

Eric

On 2/8/07, kaos <yomerosoy2005-foros@yahoo.com> wrote:

hello eric. thank you for your interest, i tried what you wrote but
unfortunately it did't work as i espected. i added the next line of
code at the end of yours

alert ("the result is: " + foo.length);

and the result is = 0 (zero)

do you have another idea??? thank you again.

On 8 feb, 11:03, "Eric Pascarello" <alienf@gmail.com> wrote:

Is your XML valid?

If you the alert the responseXML.documentElement does it return null?

If so look at this:
http://radio.javaranch.com/pascarello/2006/09/12/1158096122600.html

Eric

On 2/9/07, kaos <yomerosoy2005-foros@yahoo.com> wrote:

I think it's a valid xml file, in fact i can iterate over the file
with this.

var nodos =
originalRequest.responseXML.documentElement.getElementsByTagName('nodo');

for (count;count< nodos.length; count++){
.....//it woks fine
.....

}

and this is the file.

  <empresas name="departamentos">
  <nodo id="-1">NO UTILIZAR</nodo>
  <nodo id="01">GERENCIA DE CONTROL DE CALIDAD</nodo>
  </empresas>

but the only problem, as i commented in my first post, is that i'm not
able to get the name of the 'root', in this case "empresas",

thank you for your interest.

-----------------------------------------------Reply-----------------------------------------------

By the way, i forgot to write about the test i made.

ok if i write in the url bar  http://localhost/activosfijos/articulos/vista/listaDepartamentos.do
. this returns me the next file

<empresas name="departamentos">
    <nodo id="-1">NO UTILIZAR</nodo>
   <nodo id="01">GERENCIA DE CONTROL DE CALIDAD</nodo>
</empresas>

>>If you the alert the responseXML.documentElement does it return null?

yes it returns me the following

[object elment] in firefox
and nothing on ie 7

but alert ("the result is: " + foo.length);

is still giving me 0.

-----------------------------------------------Reply-----------------------------------------------

Do you have

<?xml version="1.0" ?>
and did you set the content type?

Eric

On 2/9/07, kaos <yomerosoy2005-foros@yahoo.com> wrote:

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc