Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jun 2010
    Posts
    293
    Thanks
    63
    Thanked 8 Times in 8 Posts

    Question "Namespace prefix q is not defined"

    I have a test docoument which looks like this:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:q="http://localhost/test-ns" xml:lang="en-gb" lang="en-gb">
      <head>
        <title>Test Document</title>
        <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
      </head>
      <body>
        <div>
          <q:test>This is a test tag</q:test>
        </div>
      </body>
    </html>
    BUT when I try to read the document in use PHP's DOMDocument::loadHTMLFile(), I get the warning Namespace prefix q is not defined.

    This has been there for a while and so far I have just switched the warning off because I don't know how to fix it ... but I would love to fix it and I am flat out of ideas on what is wrong with the markup!


  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,624
    Thanks
    6
    Thanked 1,001 Times in 974 Posts
    Is the file with the namespace definition existing and in the correct location?

  • #3
    Regular Coder
    Join Date
    Jun 2010
    Posts
    293
    Thanks
    63
    Thanked 8 Times in 8 Posts
    Yes, very much so! (P.s. appologies for posting in the wrong section - I wasn't sure if it should be in XML or HTML.)

  • #4
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,246
    Thanks
    12
    Thanked 340 Times in 336 Posts
    you should try reading it as XML, since there is no namespace in HTML.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer


  •  

    Posting Permissions

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