SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Javascript DOM

  1. #1
    SitePoint Zealot
    Join Date
    Mar 2005
    Posts
    183
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript DOM

    Hi!

    I have the following XML. Through Javascript, I have to acesss the elements (loop through) address,city,country,zipa and note and concatenate them into a string. How to achieve this? Thanks for the help

    <markers>
    <marker lat="54.749991" lng="-2.944336">
    <name><![CDATA[Admiral Bar]]></name>
    <address><![CDATA[72A Waterloo Street]]></address>
    <city><![CDATA[Glasgow]]></city>
    <country><![CDATA[UK]]></country>
    <zip><![CDATA[G2 3DA]]></zip>
    <note><![CDATA[0141 221 7705]]></note>
    </marker>
    <marker lat="51.510039" lng="-0.146047">
    <name><![CDATA[Amigos]]></name>
    <address><![CDATA[11A Union Street]]></address>
    <city><![CDATA[Torquay]]></city>
    <country><![CDATA[UK]]></country>
    <zip><![CDATA[TQ1 3DW]]></zip>
    <note><![CDATA[01803 389 444]]></note>
    </marker>
    <marker lat="51.510042" lng="-0.099607">
    <name><![CDATA[Amigos Bar & Restaurant]]></name>
    <address><![CDATA[28 Chapel Street]]></address>
    <city><![CDATA[Luton]]></city>
    <country><![CDATA[UK]]></country>
    <zip><![CDATA[LU1 2SE]]></zip>
    <note><![CDATA[01582 480 430]]></note>
    </marker>
    </markers>

  2. #2
    SitePoint Zealot
    Join Date
    Mar 2005
    Posts
    183
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am able to get it by using

    xml.childNodes(0).childNodes(i).text, but please help me to extract just ZIP Code. The first element is extracted through xml.childNodes(0).childNodes(i).firstChild.text but how about just the ZIP CODE, which is in 5th Position.

    Thanks,
    Sid

  3. #3
    SitePoint Evangelist NokX's Avatar
    Join Date
    Feb 2003
    Location
    Knoxville, TN
    Posts
    501
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i'm kinda looking for the same thing in my thread: http://www.sitepoint.com/forums/showthread.php?t=482261


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •