0

given this xml

<provincias>
  <provincia id="2" inmuebles="4" nombre="Albacete">
    <localidad id="54" nombre="ALBACETE" inmuebles="1">
      <inmuebles>
        <inmueble id="9613" tipo="segunda-mano">
          <foto>
            url/docweb/promocion/225/00052458.JPG
          </foto>
          <tipologia>Piso</tipologia>
          <tipocalle>Plaza</tipocalle>
          <nombrecalle>ISABEL II</nombrecalle>
          <numerocalle>1</numerocalle>
          <bloque/>
          <portal/>
          <escalera/>
          <planta>5º</planta>
          <puerta>A</puerta>
          <codigopostal>02005</codigopostal>
          <superficie>97</superficie>
          <superficieutil>86</superficieutil>
          <habitaciones>4</habitaciones>
          <aseos>2</aseos>
          <geolocalizacion>38.999526,-1.861082</geolocalizacion>
          <imagen src="url.../docweb/promocion/225/00052458.JPG"/>
        </inmueble>
      </inmuebles>
    </localidad>
  </provincia>
</provincias>

How can I access the tag "nombre" attribute? I've tried the following with no success:

set XmlDoc = Server.CreateObject("Microsoft.XMLDOM")
XmlDoc.async = false    
set provincias = XmlDoc.getElementsByTagName("provincia")

For Each provincia in provincias
  d1_provincia_nombre = provincia.getAttribute("nombre").value

But i keep getting : a Required object : '[string: "Albacete"]' error.

5
  • Alrite after trying some other stuff the problem was changing the line to this : d1_provincia_nombre = provincia.GetAttribute("nombre") Commented Feb 18, 2014 at 10:13
  • Sorry just seen your comment, had post window open for quite a while. If you want to post and accept your answer please do. I'll leave mine here for anyone else who comes along. Updated my answer to reflect this. Commented Feb 18, 2014 at 16:02
  • Yours was just as good and a lot more clear than than my comment,thanks again! :) Commented Feb 19, 2014 at 15:53
  • Thanks for the edit,I really need tp learn to format properly here.. Commented Feb 20, 2014 at 12:08
  • No problem more help can be found - Markdown help Commented Feb 20, 2014 at 12:11

1 Answer 1

0

I think your problem is you're specifying .value on your getAttribute when the XML DOM doesn't support it.

Try this;

'Specifying .value will give an undefined or object required error
d1_provincia_nombre = provincia.getAttribute("nombre")

See - Using Classic ASP to get value of a node attribute for more information on traversing the DOM in .

Edit: Sorry just seen your comment, had post window open for quite a while. If you want to post and accept your answer please do. I'll leave mine here for anyone else who comes along.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.