Jump to content

Search the Community

Showing results for tags 'simplexml_load_file'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 2 results

  1. I have an application that loads several xml files, and then outputs some of the data from the file. The problem is that every once in a while, the service that provides the xml file does maintenance (or has an error in the file), and my application gives a "Fatal error: Call to a member function children() on a non-object in..." I would like to handle the error differently, by displaying "unavailable" instead of the error. I know that this is usually not the appropriate way of handling errors, because there is a reason for a fatal error. Any ideas on how to appropriately handle this error? // Node 217 (GGB) $xml = simplexml_load_file("http://services.my511.org/traffic/API_KEY_REMOVED_FOR_EXAMPLE"); foreach($xml->children() as $traveltime) { $ggb = "$traveltime->currentTravelTime"; } ​echo "GGB:" , $ggb , " Minutes";
  2. I'm working through some code to display a tumblr blog on a website. Each of Tumblr's post types are easy enough to get to... <ul id="reblog"> <? foreach ($xml->posts->post as $post) { ?> <li> <? // REGULAR POSTS if ($post['type'] == "regular" ){ echo "This is a regular post"; } // PHOTO POSTS if ($post['type'] == "photo" ){ echo "This is a photo post"; } // LINK POSTS if ($post['type'] == "link" ){ echo "This is a link post"; } // AUDIO POSTS if ($post['type'] == "audio" ){ echo "This is an audio post"; } ?> </li> <? } ?> </ul> What I'm trying to do is to check and see if certain tags are used on a post, and the based on that I'll be formatting the entry a little different. I can list all of the tags, but I'm stumped on how to check the existence of a certain tag in $post->{'tag'} $xml = simplexml_load_file('http://applesold.com/assets/cache/tumblrposts.txt'); <ul id="reblog"> <? foreach ($xml->posts->post as $post) { ?> <li> <? // REGULAR POSTS if ($post['type'] == "regular" ){ echo "type of post: regular<br>"; // THIS DOESN'T WORK -- if ($post->{'tag'} == "infographic") { echo "INFOGRAPHIC"; } else { echo "non-INFOGRAPHIC"; } } ?> </li> <? } ?> </ul>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.