Re: [Gambas-user] XML problem
Brought to you by:
gambas
From: Adrien P. <adr...@gm...> - 2012-04-29 16:13:58
|
Le dimanche 29 avril 2012 18:00:11 LeszekK a écrit : > xml_r = New XmlReader > Dialog.OpenFile > > Try xml_r.Open(Dialog.Path) > > Repeat > If xml_r.Eof Then Break > xml_r.Read() > ListBox1.Add(xml_r.Node.Name) > ListBox1.Add(xml_r.Node.Value) > Wait 0.1 > Until xml_r.Eof > > xml_r.Close > > The code works correctly, but does not read the values of these lines: > <trkpt lat="51.096840000" lon="17.009750000">. > > 2012/4/29, Adrien Prokopowicz <adr...@gm...>: > > Le dimanche 29 avril 2012 17:15:16 l k a écrit : > >> Hi, I have a problem with read the value of the xml file. With this data: > >> <trkpt lat="51.096840000" lon="17.009750000"> > >> I do not know how to read value. > >> > >> With this data: > >> <time> 2012-04-29T14: 54:31 Z </time> I have no problem with that. > >> Can anyone give me some advices how to solve this? > >> > >> ------------------------------------------------------------------------- > >> --- -- Live Security Virtual Conference > >> Exclusive live event will cover all the ways today's security and > >> threat landscape has changed and how IT managers can respond. Discussions > >> will include endpoint security, mobile security and the latest in malware > >> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > >> _______________________________________________ > >> Gambas-user mailing list > >> Gam...@li... > >> https://lists.sourceforge.net/lists/listinfo/gambas-user > > > > Hi, > > > > Can you be more precise please ? Have you got any error message or can we > > have > > the code you're using ? > > > > -------------------------------------------------------------------------- > > ---- Live Security Virtual Conference > > Exclusive live event will cover all the ways today's security and > > threat landscape has changed and how IT managers can respond. Discussions > > will include endpoint security, mobile security and the latest in malware > > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > > _______________________________________________ > > Gambas-user mailing list > > Gam...@li... > > https://lists.sourceforge.net/lists/listinfo/gambas-user That's because XmlReader.Node.Value does not return the value of XML attributes. If you know the names of the attributes (here "lat" and "lon"), you can do this : xml_r = New XmlReader Dialog.OpenFile Try xml_r.Open(Dialog.Path) Repeat If xml_r.Eof Then Break xml_r.Read() ListBox1.Add(xml_r.Node.Name) ListBox1.Add(xml_r.Node.Value) If xml_r.Node.Attributes["lat"] Then ListBox1.Add(xml_r.Node.Attributes["lat"]) If xml_r.Node.Attributes["lon"] Then ListBox1.Add(xml_r.Node.Attributes["lon"]) Wait 0.1 Until xml_r.Eof xml_r.Close |