the regex approach could be useful if you validate the xml against a
DTD before parsing..

another approach would be using http://www.php.net/simplexml
SimpleXML, it is really straightforward even if you are not familiar
with typical SAX/DOM parsers!

On May 4, 5:50 pm, Mike52 <[EMAIL PROTECTED]> wrote:
> You could get the value in a "quick-and-dirty" way by using a regex.
> The function below takes the xml data as a string and you pass it the
> name of the tag:
>
>     function getTagValue($xmldata, $tag) {
>       $pattern = "/<$tag>(.*)<\/$tag>/";
>       preg_match($pattern, $xmldata, $matches);
>       return $matches[1];
>     }
>
> $coordinate = getTagValue($xmlstring, 'coordinates');
>
> On May 4, 8:54 am, David <[EMAIL PROTECTED]> wrote:
>
> > Hey folks,
>
> > I'm fairly new to Cake, so bear with me. My question is about Cake's
> > XML class:
>
> > Specifically, I'm trying to parse an XML file like this:
>
> > <kml>
> >   <Response>
> >     <name>723 Chestnut Street, Philadelphia, PA 19106</name>
> >     <Status>
> >       <code>200</code>
> >       <request>geocode</request>
> >     </Status>
> >     <Placemark id="p1">
> >       <address>723 Chestnut St, Philadelphia, PA 19106, USA</address>
> >       <AddressDetails Accuracy="8">
> >         <Country>
> >           <CountryNameCode>US</CountryNameCode>
> >           <AdministrativeArea>
> >             <AdministrativeAreaName>PA</AdministrativeAreaName>
> >             <Locality>
> >               <LocalityName>Philadelphia</LocalityName>
> >               <Thoroughfare>
> >                 <ThoroughfareName>723 Chestnut St</ThoroughfareName>
> >               </Thoroughfare>
> >               <PostalCode>
> >                 <PostalCodeNumber>19106</PostalCodeNumber>
> >               </PostalCode>
> >             </Locality>
> >           </AdministrativeArea>
> >         </Country>
> >       </AddressDetails>
> >       <Point>
> >         <coordinates>-75.153277,39.949768,0</coordinates>
> >       </Point>
> >     </Placemark>
> >   </Response>
> > </kml>
>
> > Trick is I only want the coordinates. I'm also somewhat new to working
> > with XML, so I might be missing something completely obvious here.
>
> > Anywho, I can get the XML to load fine with $feed =& new XML($url);
>
> > I just can't figure out how to parse it and get to that one piece of
> > data.
>
> > You're help is greatly appreciated. Thanks in advance.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to