How to call xml from php file to another file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • semanticnotion
    New Member
    • Sep 2010
    • 66

    How to call xml from php file to another file

    hi i have php file that reads the data from three table of mysql in xml now i want to call the xml data on this page into another page.
    how should i do this
  • semanticnotion
    New Member
    • Sep 2010
    • 66

    #2
    Code:
    $input = file_get_contents("recipe_xml.php");
    
    $xml = new SimpleXMLElement($input);
    
    
    $recipe=$xml.recipe;
    $rec_id=$xml.rec_id;
    
    echo $recipe;
    echo $rec_id;
    i do this but this gives the following error...

    Code:
    Warning: SimpleXMLElement::__construct(): Entity: line 100: parser error : Start tag expected, '<' not found in /var/www/cafe/view/update_xml.php on line 10 Call Stack: 0.0005 319164 1. {main}() /var/www/cafe/view/update_xml.php:0 0.0009 322784 2. SimpleXMLElement->__construct() /var/www/cafe/view/update_xml.php:10 Warning: SimpleXMLElement::__construct(): ?> in /var/www/cafe/view/update_xml.php on line 10 Call Stack: 0.0005 319164 1. {main}() /var/www/cafe/view/update_xml.php:0 0.0009 322784 2. SimpleXMLElement->__construct() /var/www/cafe/view/update_xml.php:10 Warning: SimpleXMLElement::__construct(): ^ in /var/www/cafe/view/update_xml.php on line 10 Call Stack: 0.0005 319164 1. {main}() /var/www/cafe/view/update_xml.php:0 0.0009 322784 2. SimpleXMLElement->__construct() /var/www/cafe/view/update_xml.php:10 Exception: String could not be parsed as XML in /var/www/cafe/view/update_xml.php on line 10 Call Stack: 0.0005 319164 1. {main}() /var/www/cafe/view/update_xml.php:0 0.0009 322784 2. SimpleXMLElement->__construct() /var/www/cafe/view/update_xml.php:10

    Comment

    • semanticnotion
      New Member
      • Sep 2010
      • 66

      #3
      what should be best approach for this

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        it looks like $input is not XML

        Comment

        Working...