• 0

[PHP] Retrieving data from an XML tag when there is a colon


Question

Now, I know my latest threads asking for help really are starting to make me sound pretty stupid :p but, yet again, I am stumped :s

I can't talk about this too much as coursemates who know I moderate Neowin may steal ideas off me ;) I will try and give as much information as possible though :)

Firstly, I am retrieving data from an XML file, in order to output and use that data for other means (eventually showing the location on a Google Map, using the Google Maps API). This has all worked out very well and I have got all of the information, including the location, from the XML file. The only problem is, I cannot get the latitude and longitude data. Both the latitude and longitude have colons in the tag names - "geo:lat" and "geo:long".

The way I have been retrieving this data works for everything except these XML tags which have colons - it puts a red squiggly line under it in Komodo Edit and says there is a parse error.

I find it odd because my process works for every tag which doesn't have a colon.

I'm not going to explain how I have parsed this XML document or retrieved the data from the document, unless I need to, because I don't want coursemates stealing ideas ;) Let's just say, it definately works because it has worked for all of the tags without colons.

I'm looking for a way to maybe escape the colons, or just anything which will work. I've tried creating a variable and assignment a colon to that, then using the variable in between "geo" and "lat" and I've tried using the str_replace() function, but that doesn't seem to work.

Here is the problem -

.$record -> venue -> location -> city.

is working

.$record -> venue -> location -> geo:point -> geo:lat.

is not working and I know it's the colons which are causing the problem as it works if I take them out (I can't just take them out though as that is not what they are called in the XML file)

Here is the XML file I am retrieving the data from.

Any help really would be very much appreciated :) Thank you in advance.

3 answers to this question

Recommended Posts

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Not to sound ungrateful for your continued presence on Neowin (which I prefer) 😛  But would you consider a subscription to just have all the third party ads turned off by us? It's $2.33 per month for the ad-free subscription, but it is also there for assistance and support with all the running costs. Like everything, it is becoming increasingly harder to do this, we even try to offset it with Amazon affiliate commissions (if we could finance totally through that instead of ads, I would) 😛 
    • Honestly, I don't remember accepting or refusing cookies following a prompt, because I've accepted or refused cookies on several other sites. On the other hand, I remember seeing  ads, before the start of the available articles (on the home page), and on the right. If the trackers I've mentioned are part of the cookies I have to accept (as well as those below), trackers that are detected by my antivirus as adware during the weekly scan, they'll remain where they are. The vast majority of cookies blocked by the Host file were added by Unchecky. I'd say so, but are Doubleclick, Scorecardresearch, Opencandy, file2desktop, etc. among those that should be accepted? If not, then I'd say no.  
    • Are you suggesting Vivaldi isn't Chromium-based or that it isn't fast? In any case, Skyfrog seems more focused on customizability.
    • "They fear that this collaboration could significantly bolster China's AI capabilities" how long is this supposed to stop china?, 5 years and then become an AI giant?, china is gonna be as big as the US in AI in no time
    • yeah... I'm gonna say this aint tech news either, don't turn this site into the verge......
  • Recent Achievements

    • Week One Done
      jbatch earned a badge
      Week One Done
    • First Post
      Yianis earned a badge
      First Post
    • Rookie
      GTRoberts went up a rank
      Rookie
    • First Post
      James courage Tabla earned a badge
      First Post
    • Reacting Well
      James courage Tabla earned a badge
      Reacting Well
  • Popular Contributors

    1. 1
      +primortal
      403
    2. 2
      +FloatingFatMan
      179
    3. 3
      snowy owl
      172
    4. 4
      ATLien_0
      170
    5. 5
      Xenon
      135
  • Tell a friend

    Love Neowin? Tell a friend!