From: "björn lundin" <b.f.lundin@gmail.com>
Subject: Re: xml/ada dropping data when pre-defined entities are separated by space?
Date: Sat, 29 Jan 2011 13:49:31 -0800 (PST)
Date: 2011-01-29T13:49:31-08:00 [thread overview]
Message-ID: <5e91567e-883f-428c-b01e-ee51e91ca30f@o8g2000vbq.googlegroups.com> (raw)
In-Reply-To: m2mxmj3a68.fsf@pushface.org
On 29 Jan, 18:13, Simon Wright <si...@pushface.org> wrote:
> There are in fact 2 nodes in the first line.
>
> Dom.Core.Nodes.Child_Nodes returns a Node_List; look in Dom.Core.Nodes
> for the Node_List operations Item and Length.
Yes, there it is:-)
Thanks for the pointer, now i get more what i like
with Input_Sources.Strings; use Input_Sources.Strings;
with Sax.Readers; use Sax.Readers;
with DOM.Readers; use DOM.Readers;
with DOM.Core; use DOM.Core;
with DOM.Core.Documents; use DOM.Core.Documents;
with DOM.Core.Nodes; use DOM.Core.Nodes;
with Ada.Text_IO;
with Unicode.CES.Basic_8bit;
procedure Test_Xml_Dom is
Xml_Str1 : String := "<?xml version='1.0' encoding='ISO-8859-1'?
><env><Row>";
xml_str2 : String := "ABC & & DEF</Row><Row>ABC &&
DEF</Row><Row>ABC _ DEF</Row></env>";
Xml_Str : String := xml_str1 & Xml_Str2;
Input : String_Input;
Reader : Tree_Reader;
Doc : Document;
List,cl : Node_List;
N,c : Node;
begin
Open(Xml_Str, Unicode.CES.Basic_8bit.Basic_8bit_Encoding,Input);
Reader.Set_Feature(Validation_Feature, False);
Reader.Set_Feature(Namespace_Feature, False);
Reader.Parse(Input);
Input.Close;
Doc := Reader.Get_Tree;
List := Get_Elements_By_Tag_Name(Doc, "Row");
for Index in 1 .. Length (List) loop
N := Item(List, Index - 1);
cl:=child_nodes(N);
Ada.Text_IO.Put_Line("Value of Row is: " & Node_Value
(First_Child (N)));
for i in 1 .. length(cl) loop
Ada.Text_IO.Put_Line("Value of node is: " & Node_Value
(item(cl,i-1)));
end loop;
end loop;
end Test_Xml_Dom;
gives
bnl@ubuntu-virtual:~$ ./test_xml
Value of Row is: ABC &
Value of node is: ABC &
Value of node is: & DEF
Value of Row is: ABC && DEF
Value of node is: ABC && DEF
Value of Row is: ABC _ DEF
Value of node is: ABC _ DEF
/Björn
next prev parent reply other threads:[~2011-01-29 21:49 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-27 10:06 xml/ada dropping data when pre-defined entities are separated by space? björn lundin
2011-01-27 11:12 ` Georg Bauhaus
2011-01-29 15:36 ` björn lundin
2011-01-29 17:13 ` Simon Wright
2011-01-29 21:49 ` björn lundin [this message]
2011-01-29 22:24 ` Simon Wright
2011-01-31 0:22 ` Georg Bauhaus
2011-01-31 8:04 ` björn lundin
2011-01-31 14:56 ` Emmanuel Briot
2011-01-31 20:17 ` björn lundin
2011-02-01 9:49 ` björn lundin
2011-02-01 18:24 ` Vadim Godunko
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox