Just installed DOMXML and getting error when loading an XML file / string

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bissatch@yahoo.co.uk

    Just installed DOMXML and getting error when loading an XML file / string

    Hi,

    I have just managed to install DOMXML on my apache/PHP setup. I am
    running PHP 4.3.0 and Apache2.

    $xmldoc = domxml_open_fil e("inc/menu.xml",
    DOMXML_LOAD_DON T_KEEP_BLANKS);

    When I try to load an XML file using the above, it gives me the
    following error:

    Warning: domxml_open_fil e(): I/O in
    C:\apache\Apach e2\htdocs\webde v\cms\inc\menu. php on line 147

    Warning: domxml_open_fil e(): warning : in
    C:\apache\Apach e2\htdocs\webde v\cms\inc\menu. php on line 147

    Warning: domxml_open_fil e(): failed to load external entity
    "inc/menu.xml" in C:\apache\Apach e2\htdocs\webde v\cms\inc\menu. php on
    line 147


    I have also tried to load the contents of the xml file into a string in
    the following way:


    $content = file_get_conten ts("inc/menu.xml");

    $xml_doc = domxml_open_mem ($content, DOMXML_LOAD_DON T_KEEP_BLANKS);


    ...giving me the following error:


    Warning: domxml_open_mem (): Opening and ending tag mismatch: opt line 4
    and menu in C:\apache\Apach e2\htdocs\webde v\cms\inc\menu. php on line
    147

    Warning: domxml_open_mem (): Premature end of data in tag menu line 2 in
    C:\apache\Apach e2\htdocs\webde v\cms\inc\menu. php on line 147


    Is PHP recognising the DOMXML functions? I have tried using an XML file
    that I know works as well as just loading a very simple one in but it
    still gives me an error. I also tried using xmldocfile() but I got the
    same error. Any ideas?

    Burnsy

  • Oli Filth

    #2
    Re: Just installed DOMXML and getting error when loading an XML file/ string

    bissatch@yahoo. co.uk said the following on 03/09/2005 14:36:[color=blue]
    > Hi,
    >
    > I have just managed to install DOMXML on my apache/PHP setup. I am
    > running PHP 4.3.0 and Apache2.
    >
    > $xmldoc = domxml_open_fil e("inc/menu.xml",
    > DOMXML_LOAD_DON T_KEEP_BLANKS);
    >
    > When I try to load an XML file using the above, it gives me the
    > following error:
    >
    > Warning: domxml_open_fil e(): I/O in
    > C:\apache\Apach e2\htdocs\webde v\cms\inc\menu. php on line 147
    >
    > Warning: domxml_open_fil e(): warning : in
    > C:\apache\Apach e2\htdocs\webde v\cms\inc\menu. php on line 147
    >
    > Warning: domxml_open_fil e(): failed to load external entity
    > "inc/menu.xml" in C:\apache\Apach e2\htdocs\webde v\cms\inc\menu. php on
    > line 147
    >
    >
    > I have also tried to load the contents of the xml file into a string in
    > the following way:
    >
    >
    > $content = file_get_conten ts("inc/menu.xml");
    >
    > $xml_doc = domxml_open_mem ($content, DOMXML_LOAD_DON T_KEEP_BLANKS);
    >
    >
    > ..giving me the following error:
    >
    >
    > Warning: domxml_open_mem (): Opening and ending tag mismatch: opt line 4
    > and menu in C:\apache\Apach e2\htdocs\webde v\cms\inc\menu. php on line
    > 147
    >
    > Warning: domxml_open_mem (): Premature end of data in tag menu line 2 in
    > C:\apache\Apach e2\htdocs\webde v\cms\inc\menu. php on line 147
    >
    >[/color]

    Can you post the XML you are trying to read?


    --
    Oli

    Comment

    • bissatch@yahoo.co.uk

      #3
      Re: Just installed DOMXML and getting error when loading an XML file / string

      > Can you post the XML you are trying to read?

      <?xml version="1.0" encoding="iso-8859-1"?>
      <menu>
      <opt title="Home" href="index.php " />
      <opt title="About us" href="about.php " />
      <opt title="Products " href="products. php" />
      <opt title="Support" href="support.p hp" />
      <opt title="Contact us" href="contact.p hp" />
      </menu>

      Burnsy

      Comment

      • bissatch@yahoo.co.uk

        #4
        Re: Just installed DOMXML and getting error when loading an XML file / string

        Ok, Ive found something out...

        It appears that I need to use the full path of the file. Ive had a
        similar problem before with relative paths but got round it using
        file_get_cotent s() and domxml_open_mem () but this time it wont let me.

        Why is it that I have used DOMXML plenty of times before and havent had
        many instances with relative paths. Is this a configuration problem? Or
        maybe its a Windows thing?

        Is there a way to get the full path of a relative file and store it in
        a string prior to using domxml_open_fil e() as I transfer stuff from my
        own computer to a server.

        Burnsy

        Comment

        • Oli Filth

          #5
          Re: Just installed DOMXML and getting error when loading an XML file/ string

          bissatch@yahoo. co.uk said the following on 04/09/2005 22:27:[color=blue]
          > Ok, Ive found something out...
          >
          > It appears that I need to use the full path of the file. Ive had a
          > similar problem before with relative paths but got round it using
          > file_get_cotent s() and domxml_open_mem () but this time it wont let me.
          >
          > Why is it that I have used DOMXML plenty of times before and havent had
          > many instances with relative paths. Is this a configuration problem? Or
          > maybe its a Windows thing?
          >[/color]

          One thing I just spotted in the manual page for domxml_open_mem ():

          "There is some interesting feature with "magic_quotes_r untime" ini
          directive and "domxml_open_me m" function.
          If we have "magic_quotes_r untime=on" in out php.ini file, this code
          generates many warning
          $xml_str = file_get_conten ts($xml_file));
          $Document = domxml_open_mem ($xml_str));
          if "magic_quotes_r untime=off" all is good."


          Does this help?

          --
          Oli

          Comment

          • Jerry Stuckle

            #6
            Re: Just installed DOMXML and getting error when loading an XML file/ string

            bissatch@yahoo. co.uk wrote:[color=blue]
            > Ok, Ive found something out...
            >
            > It appears that I need to use the full path of the file. Ive had a
            > similar problem before with relative paths but got round it using
            > file_get_cotent s() and domxml_open_mem () but this time it wont let me.
            >
            > Why is it that I have used DOMXML plenty of times before and havent had
            > many instances with relative paths. Is this a configuration problem? Or
            > maybe its a Windows thing?
            >
            > Is there a way to get the full path of a relative file and store it in
            > a string prior to using domxml_open_fil e() as I transfer stuff from my
            > own computer to a server.
            >
            > Burnsy
            >[/color]

            Check out $_SERVER['DOCUMENT_ROOT']


            --
            =============== ===
            Remove the "x" from my email address
            Jerry Stuckle
            JDS Computer Training Corp.
            jstucklex@attgl obal.net
            =============== ===

            Comment

            Working...