Solved

Pulling data from an xml file.

Posted on 2008-10-31
4
597 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 500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

726 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