Page 1 of 1

Need help pulling information from xml

Posted: Sun Jul 30, 2006 2:53 pm
by 8kobe
Everah | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


[syntax="xml"]<SearchUrls>
<Url query="05-06 Finest Shaquille O'Neal" type="Keyword">
<![CDATA[ http://www.qksrv.net/click-2039783-1037 ... ONeal_W0QQ
]]>
</Url>
<Url query="05-06 Finest Shaquille O'Neal" type="Keyword">
<![CDATA[ http://www.qksrv.net/click-2039783-1037 ... ONeal_W0QQ
]]>
</Url>
<Url query="05-06 Finest Shaquille O'Neal" type="Keyword">
<![CDATA[ http://www.qksrv.net/click-2039783-1037 ... ONeal_W0QQ
]]>
</Url>
</SearchUrls>
I have the xml feed above. I want to make links like this <a href="http://www.qksrv.net/click-2039783-1037 ... 0QQ">05-06 Finest Shaquille O'Neal</a> One for every URL in the xml. Can someone create the code I need to do this? I assume preg_match is going to be used, but I am not so great at it.


Everah | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Sun Jul 30, 2006 6:42 pm
by Ambush Commander
If you're running PHP 5, DOM or SimpleXML are the extensions to use. They are worth learning instead of implementing a quick hack in regexps.

You can also use XSLT (PHP 4) or XSL (PHP 5) for transforming XML into HTML. Also worth learning.

Of course, if you want to do it regexps, research PCRE regular expressions
. The regexp for this actually isn't that difficult. But I recommend learning the XML extensions.