Hi,

I have the following snippet of code (which works under Windows):

PROGRAM XMLTest;

USES Dom, XMLRead;

PROCEDURE ProcessItem(Node: TDOMNode);
VAR
  i: Integer;
  attr: TDOMNode;
  Title,Desc,Link,pubDate : String;
BEGIN
  Title:=''; Desc:=''; Link:=''; pubDate:='';
  WHILE Node<>Nil DO
  BEGIN
    IF (Node.NodeName='title') AND (Node.FirstChild<>Nil) THEN
      Title:=Node.FirstChild.NodeValue;   // <--- Dies here???
    IF (Node.NodeName='description') AND (Node.FirstChild<>Nil) THEN
      Desc:=Node.FirstChild.NodeValue;
    IF (Node.NodeName='link') AND (Node.FirstChild<>Nil) THEN
      Link:=Node.FirstChild.NodeValue;
    IF (Node.NodeName='pubDate') AND (Node.FirstChild<>Nil) THEN
      pubDate:=Node.FirstChild.NodeValue;
    Node:=Node.NextSibling;
  END;
END;

PROCEDURE ProcessNode(Node: TDOMNode);
BEGIN
  IF (Node.NodeName='item') AND (Node.FirstChild<>nil) THEN
    ProcessItem(Node.FirstChild)
  ELSE
  BEGIN
    IF Node.FirstChild<>nil then
      ProcessNode(Node.FirstChild);
  END;
  IF Node.NextSibling<>nil then
    ProcessNode(node.NextSibling);
END;

PROCEDURE ProcessXML(FileName: String);
VAR
  xml: TXMLDocument;
BEGIN
  ReadXMLFile(xml,FileName);
  ProcessNode(xml);
  xml.Free;
END;

BEGIN
  ProcessXML('ts2.xml');
END.


When run with this xml file it crashes in ProcessItem (when it tries to get the Title):

<?xml version="1.0" ?>
<rss version="2.0">

<channel>
<title>Test XML</title>
<ttl>60</ttl>

<item>
  <title>This is a test</title>
  <link>http://www.somewhere.com</link>
  <pubDate>Fri, 19 Aug 2005 03:58:37 -0800</pubDate>
</item>
</channel>
</rss>

Any ideas why?

--

Hilsen
  Søren

_______________________________________________
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to