Re: [flexcoders] Perplexed: An XML Love Story
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 lastmod2010-01-10T10:07:22-06:00/lastmod changefreqmonthly/changefreq priority.5/priority /url url http://www.nmh.org/nm/2-9992 lastmod2010-01-10T10:07:24-06:00/lastmod changefreqmonthly/changefreq priority.5/priority /url url http://www.nmh.org/nm/2-9998 lastmod2010-01-10T10:07:34-06:00/lastmod changefreqmonthly/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 lastmod2010-01-10T10:07:22-06:00/lastmod changefreqmonthly/changefreq priority.5/priority /url url http://www.nmh.org/nm/2-9992 lastmod2010-01-10T10:07:24-06:00/lastmod changefreqmonthly/changefreq priority.5/priority /url url http://www.nmh.org/nm/2-9998 lastmod2010-01-10T10:07:34-06:00/lastmod changefreqmonthly/changefreq priority.5/priority /url /urlset When I trace (list.*), I get this: http://www.nmh.org/nm/2-9770 lastmod2010-01-10T09:58:32-06:00/lastmod changefreqmonthly/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 lastmod2010-01-10T09:58:35-06:00/lastmod changefreqmonthly/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 lastmod2010-01-10T09:58:38-06:00/lastmod changefreqmonthly/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 lastmod2010-01-10T09:58:39-06:00/lastmod changefreqmonthly/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 lastmod2010-06-10T02:13:31-06:00/lastmod changefreqmonthly/changefreq priority.9/priority /url − url − http://www.nmh.org/nm/location+clinics+specialty+services lastmod2010-06-10T02:27:03-06:00/lastmod changefreqmonthly/changefreq priority.9/priority /url − url − http://www.nmh.org/nm/location+emergency+urgent+care lastmod2010-06-10T03:03:30-06:00/lastmod changefreqmonthly/changefreq priority.9/priority /url − url http://www.nmh.org/nm/location+gift+shops+dining lastmod2010-06-10T02:25:39-06:00/lastmod changefreqmonthly/changefreq priority.9/priority /url /urlset
Re: [flexcoders] Perplexed: An XML Love Story
Ok had a look into the raw xml also. You need to define a namespace for the schemaLocation to be bound to. Here is the code that works on my machine ... package { import flash.display.Sprite; public class Test extends Sprite { private var xml:XML = urlsset url http://www.nmh.org/nm/2-9991 lastmod2010-01-10T10:07:22-06:00/lastmod changefreqmonthly/changefreq priority.5/priority /url url http://www.nmh.org/nm/2-9992 lastmod2010-01-10T10:07:24-06:00/lastmod changefreqmonthly/changefreq priority.5/priority /url url http://www.nmh.org/nm/2-9998 lastmod2010-01-10T10:07:34-06:00/lastmod changefreqmonthly/changefreq priority.5/priority /url /urlsset; private var xml1:XML = url http://www.nmh.org/nm/location+centers lastmod2010-06-10T02:13:31-06:00/lastmod changefreqmonthly/changefreq priority.9/priority /url url http://www.nmh.org/nm/location+clinics+specialty+services lastmod2010-06-10T02:27:03-06:00/lastmod changefreqmonthly/changefreq priority.9/priority /url url http://www.nmh.org/nm/location+emergency+urgent+care lastmod2010-06-10T03:03:30-06:00/lastmod changefreqmonthly/changefreq priority.9/priority /url url http://www.nmh.org/nm/location+gift+shops+dining lastmod2010-06-10T02:25:39-06:00/lastmod changefreqmonthly/changefreq priority.9/priority /url /urlset; public function Test() { trace(xml.url.loc.text()); trace(xml1.url.loc.text()); } } } HTH, 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 lastmod2010-01-10T10:07:22-06:00/lastmod changefreqmonthly/changefreq priority.5/priority /url url http://www.nmh.org/nm/2-9992 lastmod2010-01-10T10:07:24-06:00/lastmod changefreqmonthly/changefreq priority.5/priority /url url http://www.nmh.org/nm/2-9998 lastmod2010-01-10T10:07:34-06:00/lastmod changefreqmonthly/changefreq priority.5/priority /url /urlset When I trace (list.*), I get this: http://www.nmh.org/nm/2-9770 lastmod2010-01-10T09:58:32-06:00/lastmod changefreqmonthly/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 lastmod2010-01-10T09:58:35-06:00/lastmod changefreqmonthly/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 lastmod2010-01-10T09:58:38-06:00/lastmod changefreqmonthly/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 lastmod2010-01-10T09:58:39-06:00/lastmod changefreqmonthly/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 lastmod2010-06-10T02:13:31-06:00/lastmod changefreqmonthly/changefreq priority.9/priority /url − url − http://www.nmh.org/nm/location+clinics+specialty+services lastmod2010-06-10T02:27:03-06:00/lastmod changefreqmonthly/changefreq priority.9/priority /url − url − http://www.nmh.org/nm/location+emergency+urgent+care lastmod2010-06-10T03:03:30-06:00/lastmod changefreqmonthly/changefreq priority.9/priority /url − url http://www.nmh.org/nm/location+gift+shops+dining
Re: [flexcoders] Perplexed: An XML Love Story
Yeah, you didn't add any of the namespaces in the samples. In your creation of the XML, you removed the loc node from the sample data. Point your example at http://www.nmh.org/sitemap.xml and try it.. On 8/26/2010 10:28 AM, claudiu ursica wrote: 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 lastmod2010-01-10T10:07:22-06:00/lastmod changefreqmonthly/changefreq priority.5/priority /url url http://www.nmh.org/nm/2-9992 lastmod2010-01-10T10:07:24-06:00/lastmod changefreqmonthly/changefreq priority.5/priority /url url http://www.nmh.org/nm/2-9998 lastmod2010-01-10T10:07:34-06:00/lastmod changefreqmonthly/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 lastmod2010-01-10T10:07:22-06:00/lastmod changefreqmonthly/changefreq priority.5/priority /url url http://www.nmh.org/nm/2-9992 lastmod2010-01-10T10:07:24-06:00/lastmod changefreqmonthly/changefreq priority.5/priority /url url http://www.nmh.org/nm/2-9998 lastmod2010-01-10T10:07:34-06:00/lastmod changefreqmonthly/changefreq priority.5/priority /url /urlset When I trace (list.*), I get this: http://www.nmh.org/nm/2-9770 lastmod2010-01-10T09:58:32-06:00/lastmod changefreqmonthly/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 lastmod2010-01-10T09:58:35-06:00/lastmod changefreqmonthly/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 lastmod2010-01-10T09:58:38-06:00/lastmod changefreqmonthly/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 lastmod2010-01-10T09:58:39-06:00/lastmod changefreqmonthly/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.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd; − url http://www.nmh.org/nm/location+centers lastmod2010-06-10T02:13:31-06:00/lastmod changefreqmonthly/changefreq priority.9/priority /url − url − http://www.nmh.org/nm/location+clinics+specialty+services lastmod2010-06-10T02:27:03-06:00/lastmod changefreqmonthly/changefreq priority.9/priority /url − url − http://www.nmh.org/nm/location+emergency+urgent+care lastmod2010-06-10T03:03:30-06:00/lastmod changefreqmonthly/changefreq priority.9/priority /url − url http://www.nmh.org/nm/location+gift+shops+dining lastmod2010-06-10T02:25:39-06:00/lastmod changefreqmonthly/changefreq priority.9/priority /url /urlset
Re: [flexcoders] Perplexed: An XML Love Story
Ok, how do I do that? Also, in your example, how are you iterating over the url node value to get multiples? On 8/26/2010 10:49 AM, claudiu ursica wrote: Ok had a look into the raw xml also. You need to define a namespace for the schemaLocation to be bound to. Here is the code that works on my machine ... package { import flash.display.Sprite; public class Test extends Sprite { private var xml:XML = urlsset url http://www.nmh.org/nm/2-9991 lastmod2010-01-10T10:07:22-06:00/lastmod changefreqmonthly/changefreq priority.5/priority /url url http://www.nmh.org/nm/2-9992 lastmod2010-01-10T10:07:24-06:00/lastmod changefreqmonthly/changefreq priority.5/priority /url url http://www.nmh.org/nm/2-9998 lastmod2010-01-10T10:07:34-06:00/lastmod changefreqmonthly/changefreq priority.5/priority /url /urlsset; private var xml1:XML = url http://www.nmh.org/nm/location+centers lastmod2010-06-10T02:13:31-06:00/lastmod changefreqmonthly/changefreq priority.9/priority /url url http://www.nmh.org/nm/location+clinics+specialty+services lastmod2010-06-10T02:27:03-06:00/lastmod changefreqmonthly/changefreq priority.9/priority /url url http://www.nmh.org/nm/location+emergency+urgent+care lastmod2010-06-10T03:03:30-06:00/lastmod changefreqmonthly/changefreq priority.9/priority /url url http://www.nmh.org/nm/location+gift+shops+dining lastmod2010-06-10T02:25:39-06:00/lastmod changefreqmonthly/changefreq priority.9/priority /url /urlset; public function Test() { trace(xml.url.loc.text()); trace(xml1.url.loc.text()); } } } HTH, 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 lastmod2010-01-10T10:07:22-06:00/lastmod changefreqmonthly/changefreq priority.5/priority /url url http://www.nmh.org/nm/2-9992 lastmod2010-01-10T10:07:24-06:00/lastmod changefreqmonthly/changefreq priority.5/priority /url url http://www.nmh.org/nm/2-9998 lastmod2010-01-10T10:07:34-06:00/lastmod changefreqmonthly/changefreq priority.5/priority /url /urlset When I trace (list.*), I get this: http://www.nmh.org/nm/2-9770 lastmod2010-01-10T09:58:32-06:00/lastmod changefreqmonthly/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 lastmod2010-01-10T09:58:35-06:00/lastmod changefreqmonthly/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 lastmod2010-01-10T09:58:38-06:00/lastmod changefreqmonthly/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 lastmod2010-01-10T09:58:39-06:00/lastmod changefreqmonthly/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.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd; − url http://www.nmh.org/nm/location+centers lastmod2010-06-10T02:13:31-06:00/lastmod changefreqmonthly/changefreq priority.9/priority /url − url − http://www.nmh.org/nm/location+clinics+specialty+services lastmod2010-06-10T02:27:03-06:00/lastmod changefreqmonthly/changefreq priority.9/priority /url − url − http://www.nmh.org/nm/location+emergency+urgent+care lastmod2010-06-10T03:03:30-06:00/lastmod changefreqmonthly/changefreq priority.9/priority /url − url http://www.nmh.org/nm/location+gift+shops+dining lastmod2010-06-10T02:25:39-06:00/lastmod changefreqmonthly/changefreq priority.9/priority /url /urlset
Re: [flexcoders] Perplexed: An XML Love Story
I don;t know why the copy paste did no work properly. private var xml1:XML = url http://www.nmh.org/nm/location+centers lastmod2010-06-10T02:13:31-06:00/lastmod changefreqmonthly/changefreq priority.9/priority /url url http://www.nmh.org/nm/location+clinics+specialty+services lastmod2010-06-10T02:27:03-06:00/lastmod changefreqmonthly/changefreq priority.9/priority /url url http://www.nmh.org/nm/location+emergency+urgent+care lastmod2010-06-10T03:03:30-06:00/lastmod changefreqmonthly/changefreq priority.9/priority /url url http://www.nmh.org/nm/location+gift+shops+dining lastmod2010-06-10T02:25:39-06:00/lastmod changefreqmonthly/changefreq priority.9/priority /url /urlset; You need to alter the class who produces your xml on the server to produce both the the namespace and the chema. Iterating is simple e4x syntax. trace(xml1.url.loc.text()); that produces a list of the loc nodes when queired ... I'll try to connect on your endpoint later if have the time and post the code. Is As code enough or you are using HTTPService and flex? C From: Wally Kolcz wko...@isavepets.com To: flexcoders@yahoogroups.com Sent: Thu, August 26, 2010 4:55:28 PM Subject: Re: [flexcoders] Perplexed: An XML Love Story Ok, how do I do that? Also, in your example, how are you iterating over the url node value to get multiples? On 8/26/2010 10:49 AM, claudiu ursica wrote: Ok had a look into the raw xml also. You need to define a namespace for the schemaLocation to be bound to. Here is the code that works on my machine ... package { import flash.display.Sprite; public class Test extends Sprite { private var xml:XML = urlsset url http://www.nmh.org/nm/2-9991 lastmod2010-01-10T10:07:22-06:00/lastmod changefreqmonthly/changefreq priority.5/priority /url url http://www.nmh.org/nm/2-9992 lastmod2010-01-10T10:07:24-06:00/lastmod changefreqmonthly/changefreq priority.5/priority /url url http://www.nmh.org/nm/2-9998 lastmod2010-01-10T10:07:34-06:00/lastmod changefreqmonthly/changefreq priority.5/priority /url /urlsset; private var xml1:XML = url http://www.nmh.org/nm/location+centers lastmod2010-06-10T02:13:31-06:00/lastmod changefreqmonthly/changefreq priority.9/priority /url url http://www.nmh.org/nm/location+clinics+specialty+services lastmod2010-06-10T02:27:03-06:00/lastmod changefreqmonthly/changefreq priority.9/priority /url url http://www.nmh.org/nm/location+emergency+urgent+care lastmod2010-06-10T03:03:30-06:00/lastmod changefreqmonthly/changefreq priority.9/priority /url url http://www.nmh.org/nm/location+gift+shops+dining lastmod2010-06-10T02:25:39-06:00/lastmod changefreqmonthly/changefreq priority.9/priority /url /urlset; public function Test() { trace(xml.url.loc.text()); trace(xml1.url.loc.text()); } } } HTH, 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
Re: [flexcoders] Perplexed: An XML Love Story
I am using Flex and a URLLoader. I call the loadXML in the CreationComplete event private var loader:URLLoader; private var list:XML; private function loadXML():void { loader = new URLLoader(new URLRequest(http://www.nmh.org/sitemap.xml;); loader.addEventListener(Event.COMPLETE, fileLoadedHandler); } private function fileLoadedHandler(e:Event):void { list = new XML(e.target,data); }
Re: [flexcoders] Perplexed: An XML Love Story
package { import flash.display.Sprite; import flash.events.Event; import flash.net.URLLoader; import flash.net.URLRequest; public class Test extends Sprite { private var loader:URLLoader; private var list:XML; public namespace test = http://www.sitemaps.org/schemas/sitemap/0.9;; use namespace test; private function loadXML():void { loader = new URLLoader(new URLRequest(http://www.nmh.org/sitemap.xml;)); loader.addEventListener(Event.COMPLETE, fileLoadedHandler); } private function fileLoadedHandler(e:Event):void { list = XML(e.target.data); trace(list.url.loc.text()); } public function Test() { loadXML(); } } } this works just fine on my machine... Cheers, Claduiu From: Wally Kolcz wko...@isavepets.com To: flexcoders@yahoogroups.com Sent: Thu, August 26, 2010 5:27:27 PM Subject: Re: [flexcoders] Perplexed: An XML Love Story I am using Flex and a URLLoader. I call the loadXML in the CreationComplete event private var loader:URLLoader; private var list:XML; private function loadXML():void { loader = new URLLoader(new URLRequest(http://www.nmh.org/sitemap.xml;); loader.addEventListener(Event.COMPLETE, fileLoadedHandler); } private function fileLoadedHandler(e:Event):void { list = new XML(e.target,data); }
Re: [flexcoders] Perplexed: An XML Love Story
Figured it out: private function fileLoadedHandler(e:Event):void { list = new XML(e.target.data); var n:Namespace = list.namespace(); trace(list.n::url[0].n::loc); }