I just tried your first scenario:

package {
    import flash.display.Sprite;
    
    public class Test extends Sprite
    {
        
        private var xml:XML = 
            <urlsset>
                <url>
                    http://www.nmh.org/nm/2-9991
                    <lastmod>2010-01-10T10:07:22-06:00</lastmod>
                    <changefreq>monthly</changefreq>
                    <priority>.5</priority>
                </url>
                <url>
                    http://www.nmh.org/nm/2-9992
                    <lastmod>2010-01-10T10:07:24-06:00</lastmod>
                    <changefreq>monthly</changefreq>
                    <priority>.5</priority>
                </url>
                <url>
                    http://www.nmh.org/nm/2-9998
                    <lastmod>2010-01-10T10:07:34-06:00</lastmod>
                    <changefreq>monthly</changefreq>
                    <priority>.5</priority>
                </url>
            </urlsset>;

        
        public function Test()
        {
            trace(xml.url.loc.text());
        }
    }
}


outputs:

http://www.nmh.org/nm/2-9991
http://www.nmh.org/nm/2-9992
http://www.nmh.org/nm/2-9998

Am I missing something?
C





________________________________
From: Wally Kolcz <wko...@isavepets.com>
To: flexcoders@yahoogroups.com
Sent: Thu, August 26, 2010 4:07:34 PM
Subject: [flexcoders] Perplexed: An XML Love Story

   
I am loading XML from a remote source. Then i am attempting to transverse it to 
get to the value of the 'loc' node. However, everything I am doing is coming up 
empty or an error. i am putting money its the namespace, but I dont know how to 
get around it.

I am using a pretty basic function to convert the result to an XML object.

list = new XML(e.target.data);

I tried list.url[0].loc, but it comes up blank.

When I trace (list.toXMLString()); I get this:
<urlset>
<url>
http://www.nmh.org/nm/2-9991
<lastmod>2010-01-10T10:07:22-06:00</lastmod>
<changefreq>monthly</changefreq>
<priority>.5</priority>
</url>
<url>
http://www.nmh.org/nm/2-9992
<lastmod>2010-01-10T10:07:24-06:00</lastmod>
<changefreq>monthly</changefreq>
<priority>.5</priority>
</url>
<url>
http://www.nmh.org/nm/2-9998
<lastmod>2010-01-10T10:07:34-06:00</lastmod>
<changefreq>monthly</changefreq>
<priority>.5</priority>
</url>
</urlset>

When I trace (list.*), I get this:

http://www.nmh.org/nm/2-9770
<lastmod>2010-01-10T09:58:32-06:00</lastmod>
<changefreq>monthly</changefreq>
<priority>.5</priority>
</url>
<url xmlns="http://www.sitemaps.org/schemas/sitemap/0.9";  
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
http://www.nmh.org/nm/2-9771
<lastmod>2010-01-10T09:58:35-06:00</lastmod>
<changefreq>monthly</changefreq>
<priority>.5</priority>
</url>
<url xmlns="http://www.sitemaps.org/schemas/sitemap/0.9";  
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
http://www.nmh.org/nm/2-9772
<lastmod>2010-01-10T09:58:38-06:00</lastmod>
<changefreq>monthly</changefreq>
<priority>.5</priority>
</url>
<url xmlns="http://www.sitemaps.org/schemas/sitemap/0.9";  
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
http://www.nmh.org/nm/2-9773
<lastmod>2010-01-10T09:58:39-06:00</lastmod>
<changefreq>monthly</changefreq>
<priority>.5</priority>
</url>

How to I get to the values of loc?

Here is a sample of the raw XML:

<urlset 
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd";>

−
<url>
http://www.nmh.org/nm/location+centers
<lastmod>2010-06-10T02:13:31-06:00</lastmod>
<changefreq>monthly</changefreq>
<priority>.9</priority>
</url>
−
<url>
−
http://www.nmh.org/nm/location+clinics+specialty+services
<lastmod>2010-06-10T02:27:03-06:00</lastmod>
<changefreq>monthly</changefreq>
<priority>.9</priority>
</url>
−
<url>
−
http://www.nmh.org/nm/location+emergency+urgent+care
<lastmod>2010-06-10T03:03:30-06:00</lastmod>
<changefreq>monthly</changefreq>
<priority>.9</priority>
</url>
−
<url>
http://www.nmh.org/nm/location+gift+shops+dining
<lastmod>2010-06-10T02:25:39-06:00</lastmod>
<changefreq>monthly</changefreq>
<priority>.9</priority>
</url>
</urlset>


 


      

Reply via email to