addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1linklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

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

From: Andrew U.
Sent on: Friday, September 18, 2009 1:50 PM
$xml = new SimpleXMLElement($feed);

foreach ($xml->b as $b) {
?? echo $b;
}

Andrew

On Fri, Sep 18, 2009 at 1:43 PM, Leigh <[address removed]> wrote:
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]> Chat Google Talk: henson.garth Skype: guahan.web
Contact Me Linkedin <http://www.linkedin.com/in/garthhenson>Facebook <http://www.facebook.com/henson.garth>Twitter <http://www.twitter.com/guahanweb>


--- @ WiseStamp Signature <http://www.wisestamp.com/email-install>. Get it now <http://www.wisestamp.com/email-install>




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_desc'];
? ? ? ? }

? ?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.com/49/
? ?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.com/49/members/1655645/
? ?To unsubscribe or to update your mailing list settings, click
? ?here: http://www.meetup.com/account/comm/
? ?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.com/49/>.
To learn more about Garth Henson, visit his/her member profile <http://php.meetup.com/49/members/8572491/>

To unsubscribe or to update your mailing list settings, click here <http://www.meetup.com/account/comm/>

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.washington.edu/envhlth/

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







--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
http://php.meetup.com/49/
This message was sent by Leigh ([address removed]) from The Seattle PHP Meetup Group.
To learn more about Leigh, visit his/her member profile: http://php.meetup.com/49/members/1655645/
To unsubscribe or to update your mailing list settings, click here: http://www.meetup.com/account/comm/
Meetup Support: [address removed]
632 Broadway, New York, NY 10012 USA




--
Stephen Hawking: "My goal is simple. It is a complete understanding of the universe, why it is as it is and why it exists at all."

Our Sponsors

  • PluralSight

    PluralSight subscriptions for developer training

  • O'Reilly

    Disc Code: PCBW is good for 40% off print and 50% off ebooks and videos

  • JetBrains PhpStorm

    Occasional free licenses to raffle off at meetups

  • DynaTrace

    Find yourself, promote yourself, stay true to yourself.

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