Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7410991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:19:04+00:00 2026-05-29T06:19:04+00:00

I’m having a problem with some PHP code I’m trying to use. I keep

  • 0

I’m having a problem with some PHP code I’m trying to use. I keep getting an “unexpected T_STRING” error? This is the code on my test page:

   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
   <html xmlns="http://www.w3.org/1999/xhtml">

    <?php
    include 'http://www.weather.gov/xml/current_obs/KTPA.xml';

    $current_observation = new SimpleXMLElement($xmlstr);

    echo $current_observation->location[0]->plot;
    echo $current_observation->weather[0]->plot;
    echo $current_observation->temperature_string[0]->plot;
    echo $current_observation->wind_string[0]->plot;

    ?>

What I’m wanting to do is pull weather data from this National Weather Service XML file, and display it in a way similar to how the NWS is doing it on that page. However, the above code returns this message: “Parse error: syntax error, unexpected T_STRING in http://www.weather.gov/xml/current_obs/KTPA.xml on line 1″. Is this something I can fix? I’m new to PHP, so any help you can provide will be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:19:05+00:00Added an answer on May 29, 2026 at 6:19 am

    First of all this script should be run before the html and doctype tags, you did not finish your html code with head and body Those should always be the basic for your html webpage.

    Second of all where does $xmlstr points to, you have never created the variable $xmlstr, and the webpage you include is xml so that one doesn’t do it either.
    If you are using your own set up webserver you could enable cUrl where you can parse the xml sourcecode, saving it into variables and showing it step by step using an array and a for-loop.
    You would save the parsed data in an array like:

    with cUrl you get an output which you can save in a variable, lets say $output.
    from there on you would have to echo your way parsing step by step, so first you would do echo $output; so you know what the source actually looks like when using cUrl, next step is to find the specific data in that url and parse your way to that point using explode (creates arrays) and substrings, and you can save those into an array like:
    $city[$cityName][$temp] or someting like that

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to create an if statement in PHP that prevents a single post
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.