andymike07 Posted November 20, 2007 Share Posted November 20, 2007 Hi, I'm working on a script to get XML data from another site and importing the data into a database, but I've run into a snag. The company that produces the feed decided to include an image I need in a block of html code. I'd like to know the best way to get the URL of the image and ignore the rest of the HTML. I have included a sample layout of the feed below. (Hope it helps.) <summary type="html"> <div id="boxcover"><a href="http://fakeurl.com"><img src="http://fakeurl.com/image/boxcover/a99743_65w100h.jpg" /></a></div> <p>Text about the movie here. Text about the movie here. Text about the movie here. Text about the movie here. Text about the movie here. Text about the movie here. Text about the movie here. Text about the movie here. Text about the movie here.</p> <p> Text about the movie here. Text about the movie here. Text about the movie here. Text about the movie here. Text about the movie here. Text about the movie here. Text about the movie here. </p> </summary> Quote Link to comment Share on other sites More sharing options...
mattd8752 Posted November 20, 2007 Share Posted November 20, 2007 explode it limiting 2 both times. <img src=" getting exploded first and taking element 1 (the rest of the string) then explode " and take the first part. Getting you the URL of the image. Or you could go the more advanced way of regex. Quote Link to comment Share on other sites More sharing options...
andymike07 Posted November 20, 2007 Author Share Posted November 20, 2007 ah thanks mattd. that worked perfectly. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.