Jump to content

Search the Community

Showing results for tags 'simplexml parsing xml'.

  • 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 1 result

  1. Hello, I have a small problem and I have been searching for hours. While I have found many results. I really haven't found one that works with the code I am currently using or I am just not knowledgeable enough about it. I am using SimpleXML to parse a XML feed. I have never used SimpleXML so I decided on this current script I would give it a shot. This is the structure of the XML I am working with below. The elements with the namespaces I am needing is <cap:event>, <cap:effective>, <cap:expires>, <cap:severity> <entry> <id>http://alerts.weather.gov/cap/wwacapget.php?x=TX124EFFB832F0.SpecialWeatherStatement.124EFFB84164TX.LUBSPSLUB.ac20a1425c958f66dc159baea2f9e672</id> <updated>2013-05-06T20:08:00-05:00</updated> <published>2013-05-06T20:08:00-05:00</published> <author> <name>w-nws.webmaster@noaa.gov</name> </author> <title>Special Weather Statement issued May 06 at 8:08PM CDT by NWS</title> <link href="http://alerts.weather.gov/cap/wwacapget.php?x=TX124EFFB832F0.SpecialWeatherStatement.124EFFB84164TX.LUBSPSLUB.ac20a1425c958f66dc159baea2f9e672"/> <summary>...SIGNIFICANT WEATHER ADVISORY FOR COCHRAN AND BAILEY COUNTIES... AT 808 PM CDT...NATIONAL WEATHER SERVICE DOPPLER RADAR INDICATED A STRONG THUNDERSTORM 30 MILES NORTHWEST OF MORTON...MOVING SOUTHEAST AT 25 MPH. NICKEL SIZE HAIL...WINDS SPEEDS UP TO 40 MPH...CONTINUOUS CLOUD TO GROUND LIGHTNING...AND BRIEF MODERATE DOWNPOURS ARE POSSIBLE WITH</summary> <cap:event>Special Weather Statement</cap:event> <cap:effective>2013-05-06T20:08:00-05:00</cap:effective> <cap:expires>2013-05-06T20:45:00-05:00</cap:expires> <cap:status>Actual</cap:status> <cap:msgType>Alert</cap:msgType> <cap:category>Met</cap:category> <cap:urgency>Expected</cap:urgency> <cap:severity>Minor</cap:severity> <cap:certainty>Observed</cap:certainty> <cap:areaDesc>Bailey; Cochran</cap:areaDesc> <cap:polygon>34.19,-103.04 34.19,-103.03 33.98,-102.61 33.71,-102.61 33.63,-102.75 33.64,-103.05 34.19,-103.04</cap:polygon> <cap:geocode> <valueName>FIPS6</valueName> <value>048017 048079</value> <valueName>UGC</valueName> <value>TXZ027 TXZ033</value> </cap:geocode> <cap:parameter> <valueName>VTEC</valueName> <value></value> </cap:parameter> </entry> This is a sample of the php I am using to parse the XML and it works great for normal non-namespace elements. It does exactly what I need it to do. My question is, what do I need to do to parse the elements with namespaces cap: with the including code below? ini_set('display_errors','1'); $tdata = ""; $data = "http://alerts.weather.gov/cap/tx.php?x=1"; $entries = simplexml_load_file($data); if(count($entries)): //Registering NameSpace $entries->registerXPathNamespace('prefix', 'http://www.w3.org/2005/Atom'); $result = $entries->xpath("//prefix:entry"); foreach ($result as $entry): $title = $entry->title; $summary = $entry->summary; $tdata .= "<p><strong>$title</strong></p><p>$summary</p><hr/>"; endforeach; endif; Any suggestions would be greatly appreciated as I have gotten this far and I can't seem to tackle this last small obstacle. -Thanks
×
×
  • 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.