Re: [php-49] if statement to call out html tag

From: Leigh
Sent on: Friday, September 18, 2009 1:43 PM
Oh, the xml is not my feed, so I can't restructure it. I just want to 
grab the whatever is in the <b> tag to display in my website.


Garth Henson wrote:
> Ideally, you wouldn't have to specify an actual tag to select from 
> within an XML feed. If you are controlling the XML feed, I would 
> recommend restructuring the description like so and grabbing just the 
> portion you need for display:
>
> <event_desc>
>     <author>My Author</author>­
>     <title>My Title</title>
> </event_desc>
>
> I understand that this may not always be possible, so to more directly 
> answer the question, I would recommend doing a regular expression 
> match on the text to retrieve the portion you are seeking. Something 
> like this should do the trick:
>
> <?php
> $string = "<b>Author<­/b> <p>Title</p­>";
> if (preg_match('|<b>­(.*?)</b>|", $string, $match))
> {
>     $author = $match[1];
> }
> ?>
>
> Hope this helps.
>
> Garth Henson
> Guahan Web
> Email: [address removed] <mailto:[address removed]>
> Web: http://www.guahan...­
> Chat Google Talk: henson.garth Skype: guahan.web
> Contact Me Linkedin <http://www.linked...­ 
> <http://www.facebo...­ 
> <http://www.twitte...;­
>
>
> --- @ WiseStamp Signature <http://www.wisest...;­. 
> Get it now <http://www.wisest...;­
>
>
>
> On Fri, Sep 18, 2009 at 4:26 PM, Leigh <[address removed] 
> <mailto:[address removed]>> wrote:
>
>     Hi. I'm a newbie with php so let me know if what I'm writing doesn't
>     make sense.
>
>     I'm trying to do an if statement by grabbing a data from an xml feed.
>     Now grabbing the whole data is fine but what I'm trying to do is just
>     grab the html tag <b></b>.­
>
>     XML Feed:
>     <event_desc>
>     <B>Author Name</B>  <P>Book Title</p>
>     </event_desc>
>
>     STATEMENT:
>     if ( ??? == <B> ) {
>          echo $thedataobj['event_d­esc'];
>          }
>
>     How would I call the html tag that I need?
>
>     Leigh
>
>
>
>     --
>     Please Note: If you hit "REPLY", your message will be sent to
>     everyone on this mailing list ([address removed]
>     <mailto:[address removed]>)
>     http://php.meetup...­
>     This message was sent by Leigh ([address removed]
>     <mailto:[address removed]>) from The Seattle PHP Meetup Group.
>     To learn more about Leigh, visit his/her member profile:
>     http://php.meetup...­
>     To unsubscribe or to update your mailing list settings, click
>     here: http://www.meetup...­
>     Meetup Support: [address removed] <mailto:[address removed]>
>     632 Broadway, New York, NY 10012 USA
>
>
>
>
>
>
> --
> Please Note: If you hit "*REPLY*", your message will be sent to 
> *everyone* on this mailing list ([address removed] 
> <mailto:[address removed]>)
> This message was sent by Garth Henson ([address removed]) from The 
> Seattle PHP Meetup Group <http://php.meetup...;­.
> To learn more about Garth Henson, visit his/her member profile 
> <http://php.meetup...;­
> To unsubscribe or to update your mailing list settings, click here 
> <http://www.meetup...;­
>
> Meetup Support: [address removed]
> 632 Broadway, New York, NY 10012 USA 


-- 
********************­********************­*****************

Ly Pham										    
Web Designer
UW-DEOHS							
HSB E-179D, Box[masked]     					
Seattle, WA[masked]				
Phone:[masked] || Fax: [masked]					
http://depts.wash...­

OFFICE HOURS
Tuesday & Thursday: 9:30-3
Friday: 12-3



Our Sponsors

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy