Einzelnen Beitrag anzeigen

Skyruner2

Registriert seit: 26. Okt 2003
93 Beiträge
 
Delphi 7 Professional
 
#7

Re: Only one top level element is allowed in an XML document

  Alt 23. Jun 2004, 17:56
die lösung via experts-exchange.com :


Zitat von Workshop_Alex @ Experts-exchange.com:
First of all, download XMLSpy from http://xmlspy.com/ since it's a real useful tool. If you can afford it, buy the professional version...

I checked your XML file and it seems to be okay. However, the line:
<?xml version="1.0" encoding="UTF-8"?>
Seems to be missing. Not a real problem, though.

Be aware that you can only have one top level node in an XML file. Thus:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<MakeItReal_settings>
  <Bla/>
</MakeItReal_settings>
<MakeItReal_settings>
  <Bla/>
</MakeItReal_settings>
This would be illegal since you have two MakeItReal_settings root nodes. Furthermore, XML is case-sensitive thus MakeItReal_settings and makeitreal_settings are two different nodes. But you probably know this already.

No, wait. You forgot about the case-sensitivity...

xml:=xmlsettings.ChildNodes.Nodes['Makeitreal_settings'].ChildNodes.FindNode('AppSettings');
weathernode:=Main.XMLsettings.ChildNodes.Nodes['MakeItReal_settings'].ChildNodes.FindNode('WeatherStates');

You spelled it Makeitreal_settings and MakeItReal_settings which explains your error. It tries to create a new root node called MakeItReal_settings which of course isn't allowed.

Oops...
  Mit Zitat antworten Zitat