?
Solved

Pulling data from an xml file.

Posted on 2008-10-31
4
Medium Priority
?
605 Views
Last Modified: 2012-06-21
Trying to import an XML file into a database using Binkers example:
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/XML/Q_22939751.html

Getting Error:
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 1: parser error : Start tag expected, '<' not found in /home/tylerweb/public_html/replay247.com/xml_test.php on line 24

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: $return in /home/tylerweb/public_html/replay247.com/xml_test.php on line 24

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /home/tylerweb/public_html/replay247.com/xml_test.php on line 24

Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /home/tylerweb/public_html/replay247.com/xml_test.php:24 Stack trace: #0 /home/tylerweb/public_html/replay247.com/xml_test.php(24): SimpleXMLElement->__construct('$return') #1 {main} thrown in /home/tylerweb/public_html/replay247.com/xml_test.php on line 24

Line 24: $xml = new SimpleXMLElement($xmlstr);:


$url = "http://fccwebservice.freeconferencecall.com/fcc.asmx/RegisterByName?Partner=replay247&FullName=Jeffrey%20Morris&Email=jeff@jncmorris.com&TestMode=false";
 
// echo "\n$url";
 $ch = curl_init($url);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 
 $return=curl_exec ($ch);
 curl_close ($ch);
 
$xmlstr = '$return';
$xml = new SimpleXMLElement($xmlstr);
//@$xml = new SimpleXMLElement($xmlstr); 
 
 
$sql = ("INSERT INTO tblconfline (MemberID, FCCID, FCCPhonenumber, FCCAccessCode, FCCPIN, FCCPlaybackNumber, FCCErrorMsg, FCCTestMode, RecDate)
VALUES
('" . $_SESSION['memberid'] . "', 
'" . $xml->FCCID . "', 
'" . $xml->FCCPhonenumber . "', 
'" . $xml->FCCAccessCode . "', 
'" . $xml->FCCPIN . "', 
'" . $xml->FCCPlaybackNumber . "', 
'" . $xml->FCCErrorMsg . "', 
'" . $xml->FCCTestMode . "',  
NOW())") or die ("Error adding the record"); 
$result = mysql_query($sql) or die ('Database error: '. mysql_error());
if ($result) { echo "updated <br>"; }

Open in new window

0
Comment
Question by:Jeff
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 82

Accepted Solution

by:
hielo earned 2000 total points
ID: 22853355
instead of:
$xml = new SimpleXMLElement($xmlstr);

try:
$xml = new SimpleXMLElement( file_get_contents($url) );
0
 

Author Comment

by:Jeff
ID: 22853901
That's why you're the Guru!
Thanks again!

Quick question:
$xml = new SimpleXMLElement( file_get_contents($url) );
@$xml = new SimpleXMLElement( file_get_contents($url) );

What does the @ do?
0
 
LVL 82

Expert Comment

by:hielo
ID: 22854076
>>What does the @ do?
supresses any potential warning/error messages. Without it, the warning/error will be sent to the browser.
0
 
LVL 82

Expert Comment

by:hielo
ID: 22854232
glad to help
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question