Einzelnen Beitrag anzeigen

Klaus01

Registriert seit: 30. Nov 2005
Ort: München
5.755 Beiträge
 
Delphi 10.4 Sydney
 
#1

XML: Fehler beim Einlesen eines XML Streams

  Alt 20. Jan 2007, 17:09
Guten Abend,
mit dem folgenden Code lese ich XML Streams ein:
Delphi-Quellcode:
...
   if xmlStream.Size > 0 then
     begin

       XMLDocument1.LoadFromStream(xmlStream); // hier tritt das Problem auf.
       XMLDocument1.Active:=true;

         ANode:=XMLDocument1.DocumentElement.ChildNodes.FindNode('channel');

     // with treeview1.Items.AddFirst(nil,ANode.ChildNodes['title'].Text) do
     // selected:=true;

       StartItemNode:=XMLDocument1.DocumentElement.ChildNodes.First.ChildNodes.FindNode('item');

       ANode:=StartItemNode;
       repeat
          //treeview1.Items.AddChild(treeview1.Selected,
          data.itemTitle:=getText(ANode.ChildNodes.FindNode('title'));
          data.itemUrl:=ANode.ChildNodes.FindNode('enclosure').Attributes['url'];
          data.itemLength:=StrToInt(ANode.ChildNodes.FindNode('enclosure').Attributes['length']);
          //Node.selectSingleNode("enclosure").ge
          TFeed(List[number]).addItem(data);
          ANode:=ANode.NextSibling;
       until ANode = nil;
     end;
   xmlDocument1.Active:=false;
   xmlStream.Free;
end;
wobei XMLDocument vom Typ TXMLDocument ist.

Normalerweise funktioniert der Code ohne Probleme, nur bei dieser XML Datei macht er Probleme.
Delphi gibt diese Fehlermeldung aus: EDOMParseError : 'An invalid character was found in text content.
<description> A preview of the coming'

Stolpert der Parser über die &amp; Tags im Text?

Nun ich könnte

XMLDocument1.LoadFromStream(xmlStream);
in try .. except einpacken.

Aber was mich interessiert, ist die Schreibweise mit &amp; im XML Text nicht XML konform oder
hat der Parser einen Bug?

Hier ein Auszug der XML Datei.

XML-Code:
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
   <channel>
      <title>Radio 1 Documentaries</title>
      <link>http://www.bbc.co.uk/radio1/documentaries/podcast.shtml</link>
      <description>Sex, drugs, UFOs, soldiers, saving the planet...have you got an opinion on these issues? Colin Murray has and the Radio 1 documentaries podcast will give you all the shizzle...what they think, what we think, and most importantly what YOU have to say. For more information and podcast terms of use go to www.bbc.co.uk/radio1</description>
      <itunes:author>BBC Radio 1</itunes:author>

      <itunes:owner>
         <itunes:name>BBC</itunes:name>
          <itunes:email>podcasting@bbc.co.uk</itunes:email>
      </itunes:owner>
      <language>en-gb</language>
      <ttl>720</ttl>
      
      <itunes:image href="http://www.bbc.co.uk/radio/downloadtrial/images/programmes/300x300/radio1_interviews.jpg"/>

      
      <copyright>(C) BBC 2006</copyright>
      <pubDate>Fri, 19 Jan 2007 16:43:52 +0000</pubDate>
      <itunes:category text="Music"/><itunes:category text="Health"/>
      
      <itunes:keywords>BBC,Radio1,Radio,Music,Sex,Drugs,Documentary</itunes:keywords>
      <itunes:explicit>No</itunes:explicit>
      
      <item>

         <title>Documentary: Film 07</title>
         <description>A preview of the coming year in film, with exclusive on set audio diary from the UK&#65533;s hottest film makers, Hammer &amp; Tongs, as they work on the follow up to their box office smash, Hitchhikers Guide To The Galaxy. Colin also chats film with Simon Pegg &amp; Nick Frost.</description>
         <itunes:subtitle>Documentary: Film 07</itunes:subtitle>
         <itunes:summary>A preview of the coming year in film, with exclusive on set audio diary from the UK&#65533;s hottest film makers, Hammer &amp; Tongs, as they work on the follow up to their box office smash, Hitchhikers Guide To The Galaxy. Colin also chats film with Simon Pegg &amp; Nick Frost.</itunes:summary>

         <pubDate>Fri, 19 Jan 2007 16:00:00 +0000</pubDate>
         <itunes:duration></itunes:duration>
         <guid isPermaLink="false">http://downloads.bbc.co.uk/rmhttp/downloadtrial/radio1/radio1documentaries/radio1documentaries_20070119-1600_40_pc.mp3</guid>
         <enclosure
            url="http://downloads.bbc.co.uk/rmhttp/downloadtrial/radio1/radio1documentaries/radio1documentaries_20070119-1600_40_pc.mp3"
            length="12570149"
            type="audio/mpeg"/>
         <media:content url="http://downloads.bbc.co.uk/rmhttp/downloadtrial/radio1/radio1documentaries/radio1documentaries_20070119-1600_40_pc.mp3"
            fileSize="12570149"
            type="audio/mpeg"
            expression="full"
            duration=""
            bitrate="40"/>
         
      </item>
Die Fehlermeldung und die XML Datei habe ich angehängt.
Wäre schön, wenn jemand etwas Licht in die Sache bringen könnte.

Grüße
Klaus
Miniaturansicht angehängter Grafiken
xml-error_935.jpg  
Angehängte Dateien
Dateityp: xml rss_111.xml (4,1 KB, 7x aufgerufen)
Klaus
  Mit Zitat antworten Zitat