SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,051
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    XML Parsing Error

    Hi- I am trying to open up the following xml file in my browser, but it gives me the error shown below;

    Url: http://localhost/software/versions/w...-ver.2.5.1.xml

    Xml file:
    PHP Code:
    <?xml version="1.0" encoding="utf-8"?>
    <version>2.5.1</version>
    <supported>2.5</supported>
    Error:
    Code:
    XML Parsing Error: junk after document element
    Location: http://localhost/software/versions/working/upgrade-ver.2.5.1.xml
    Line Number 3, Column 1:<supported>2.5</supported>
    ^

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Pretty sure you need a root element, you don't appear to have one.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    SitePoint Evangelist
    Join Date
    Jun 2006
    Location
    Wigan, Lancashire. UK
    Posts
    523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    An XML document can only have a single top level node. You have two: version and supported

    [code=xml]
    <?xml version="1.0" encoding="utf-8"?>
    <data>
    <version>2.5.1</version>
    <supported>2.5</supported>
    </data>
    [/code]
    ---
    Development Projects:
    PHPExcel
    PHPPowerPoint

  4. #4
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,051
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mark Baker View Post
    An XML document can only have a single top level node. You have two: version and supported

    [code=xml]
    <?xml version="1.0" encoding="utf-8"?>
    <data>
    <version>2.5.1</version>
    <supported>2.5</supported>
    </data>
    [/code]
    Ok, great- thanks. That seems to have fixed that problem. Now I have an issue on line 265. Line 265 contains a MySQL query within the <command></command> tags. What do I have to put around the sql query so that XML does not throw out an error?

    Line 265:
    Code:
    <command>update `".$temp_prefix."table` set `language` = 'english',`page_name` = 'index',`array_key` = 'welcome_text',`phrase` = '<p><strong>Software</strong></p>' where `".$temp_prefix."phrases`.`page_name` = 'index' and `".$temp_prefix."phrases`.`array_key` = 'welcome_text'</command>

  5. #5
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <![cdata[ Sql_statement ]]>
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  6. #6
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,051
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just tried the following code on 165, but still getting the error below;

    Line 165:
    Code XML:
    <![cdata[update `".$temp_prefix."table` set `language` = 'english',`page_name` = 'index',`array_key` = 'welcome_text',`phrase` = '<p><strong>Software</strong></p>' where `".$temp_prefix."phrases`.`page_name` = 'index' and `".$temp_prefix."phrases`.`array_key` = 'welcome_text']]>

    Error:

    Code:
    XML Parsing Error: not well-formed
    Location: http://localhost/software/versions/working/2.5.1/upgrade-ver.2.5.1.xml
    Line Number 265, Column 7:	  <![cdata[update `".$temp_prefix."table` set `language` = 'english',`page_name` = 'index',`array_key` = 'welcome_text',`phrase` = '<p><strong>Software</strong></p>' where `".$temp_prefix."phrases`.`page_name` = 'index' and `".$temp_prefix."phrases`.`array_key` = 'welcome_text']]>
    -------------^

  7. #7
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    You would need to post your code, your PHP isn't being evaluated, but it should be something similar to...
    PHP Code:
    <?xml version="1.0" encoding="utf-8"?>
    <root>
      <action>
        <method>update</method>
        <sql><![CDATA[UPDATE table SET <?php echo $foo?> = 'bar' WHERE breakfast = 'bacon']]></sql>
      </action>
    </root>
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  8. #8
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,051
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SilverBulletUK View Post
    You would need to post your code, your PHP isn't being evaluated, but it should be something similar to...
    PHP Code:
    <?xml version="1.0" encoding="utf-8"?>
    <root>
      <action>
        <method>update</method>
        <sql><![CDATA[UPDATE table SET <?php echo $foo?> = 'bar' WHERE breakfast = 'bacon']]></sql>
      </action>
    </root>
    Managed to figure it out, thanks!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •