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
Solved

Pulling data from an xml file.

Posted on 2008-10-31
4
595 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
  • 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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Suggested Solutions

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
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. 
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

828 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