Loading UCS-2(UTF-16) XML file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sm0a9f4
    New Member
    • Mar 2008
    • 2

    Loading UCS-2(UTF-16) XML file

    Hi everyone,
    I'm a noob with a problem...
    In non-IE browsers, I'm trying to load a UCS-2 (UTF-16) encoded file using the following lines:
    xmlDoc=document .implementation .createDocument ("settings.xml" ,"",null);
    xmlDoc.async=fa lse;
    xmlDoc.load("") ;
    I get an error on the last line that says "Value Undefined (result expression xmlDoc.load) is not an object."
    1.) Do I have to specify an encoding type when loading a an XML file? (There already is an encoding line on the first line of my XML file which says <?xml version="1.0" encoding="ucs-2"?>
    2.) The XML has no text elements (i.e. all the values are stored as attributes for each element). Should I use another method for loading this file?
  • rnd me
    Recognized Expert Contributor
    • Jun 2007
    • 427

    #2
    Originally posted by sm0a9f4
    1.) Do I have to specify an encoding type when loading a an XML file? (There already is an encoding line on the first line of my XML file which says <?xml version="1.0" encoding="ucs-2"?>
    2.) The XML has no text elements (i.e. all the values are stored as attributes for each element). Should I use another method for loading this file?

    1. no, it will be detected automatically. if the BOM is incorrect however, you will run into problems.

    2. i would use another method yes, but not because of the structure of the XML data, that shouldn't matter.

    Comment

    • sm0a9f4
      New Member
      • Mar 2008
      • 2

      #3
      Thank you for answering my 2 questions, but can you tell me what I'm doing wrong? Why do I get that error when trying to load the file?

      Comment

      • rnd me
        Recognized Expert Contributor
        • Jun 2007
        • 427

        #4
        your syntax is incorrect. you pass filename upon calling the load function.


        here is an example from w3schools


        Code:
        xmlDoc=document.implementation.createDocument("","",null);
        xmlDoc.async="false";
        xmlDoc.load("books.xml");

        Comment

        Working...