• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

RootElement is null

 
Ranch Hand
Posts: 529
C++ Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I am just learning about XML, and I have a strange problem with an exercise in my book. I am trying to load an XML document with JavaScript, but after it is loaded, browser complains that RootElement is null. The filename is definitely correct and the XML file is "well-formed." I can load other XML files from other exercises using the same JavaScript just fine (just changing the filename in the load() method). Could someone please take a look at the code below, and see if they can find a problem. I am stumped! Thanks a lot!!!
The XML:

The HTML and JavaScript:


[This message has been edited by Barry Andrews (edited January 01, 2002).]
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Barry,
There is a problem with specifying xml namespace,<i>dt</i> in your xml file at the root element, Book. Change <b>urn</b> to <b>uri</b>.
xmlns:dt="uri:schemas-microsoft-com:datatypes"
Hope it will work.

------------------
Yan Naing Wynn Tint (SCJP2, SCWCD)
 
YanNaing WTint
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Barry,
my previous solution is not a correct and proper way.
"urn:schemas-microsoft-com:datatypes" is the correct usage for Unified Resource Name.
The namespace you are using is microsoft datatype schema defination. And the field for that schema is "type". So you must use "dt:type" instead of "dt:dt".
you can check more info at..
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/htm/xml_tutorial_3x2r.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wss/wss/_cdo_schema_datatypes.asp

------------------
Yan Naing Wynn Tint (SCJP2, SCWCD)
 
Barry Andrews
Ranch Hand
Posts: 529
C++ Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
YanNaing,
Thanks for your reply! But, if I load another XML file that uses "dt:dt" it works fine, which makes me think there is some other problem. Nevertheless, I will try your suggestion to see if it makes a difference.
Thanks,
Barry
 
Barry Andrews
Ranch Hand
Posts: 529
C++ Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
YanNaing,
Now I am a little confused. I changed the "dt t" to "dt:type" in my XML code, and it worked just like you said it would. But, I have many other examples (all from the book) that I have been using successfully with "dt t". Do you or anyone else have any ideas as to why this is?
Thanks,
Barry
 
YanNaing WTint
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Barry,
That is an interesting story. Would you give me one of the other working example using dt t. Let me take a look at it. BTW, what brower and version are you using?
Here is the good tutorial, I hope it would help your learning.
web page
 
Barry Andrews
Ranch Hand
Posts: 529
C++ Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is one that works using "dt:dt". I am using IE6.0. Thanks for the tutorial!
 
YanNaing WTint
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Barry,
Good News.
The problem is at <PublicationDate dt:dt="date">12/20/99</PublicationDate>. In fact, the format of the element content,"12/20/99". The schema that allow the date data type is "CCYY-MM-DD". I think this is MS Xml schema specification. The correct one is like <PublicationDate dt:dt="date">1999-12-20</PublicationDate>.
good luck,
 
Barry Andrews
Ranch Hand
Posts: 529
C++ Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ohhhhhhhhhhhhhhhhhh!!! I see! Yes, that is the problem! I am using BEA XML Editor. It has a parsing feature, but I guess it doesn't actually validate the datatypes. I guess that is asking to much... Thank you very much for your help!

Barry
 
YanNaing WTint
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are very welcome....
 
It's weird that we cook bacon and bake cookies. Eat this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic