[Gambas-user] How to create xml from table view?

wahyu budhi webs37 at ...626...
Fri May 8 06:49:50 CEST 2009


On Thu, May 7, 2009 at 8:19 PM, Sergio A. Hernandez <info.geex at ...626...>wrote:

> I just wrote this example for a different subject.
> All you need to do is to encapsule the <tr> related lines in a
> external loop for each row,
> then you need to include the <td> lines in a internal loop for each column.
>
> Obviously, you can rename the <style>, <table>, <tr> & <td>, elements
> for those you consider more appropriate.
>
> > Try the following. It is a complete different approach using the XML
> Writer.
> > Try it as a console project, just make sure you the gb.xml is selected
> under
> > PROJECT\PROPERTIES\COMPONENTS
> >
> > ' Gambas module file
> > PUBLIC SUB Main()
> >  DIM docXML AS XmlWriter
> >
> >  docXML = NEW XmlWriter
> >  'this line is to save the xml document in your home folder
> >  docXML.Open(User.Home & "/DoctorRicky.html", TRUE)
> >
> >  'This part is the fancy CSS styling only is not important
> >  docXML.StartElement("style", ["type", "text/css"])
> >    docXML.Text("table.fancyTable {padding: 2pt; widht:100%;}")
> >    docXML.Text("th {font-weight: bold; background-color: #cccc99;
> > color: #000000}")
> >    docXML.Text("tr.evenRow {background-color: #f5f5dc; text-align:
> center}")
> >    docXML.Text("tr.oddRow {background-color: #ffffff; text-align:
> center}")
> >  docXML.EndElement
> >
> >  docXML.StartElement("table", ["class", "fancyTable"])
> >   '<th /> is the HTML tab for the headers
> >   docXML.Element("th", "Test")
> >   docXML.Element("th", "Date 1")
> >   docXML.Element("th", "Date 2")
> >   docXML.Element("th", "Date 3")
> >   '<tr /> is the tag for the rows
> >   docXML.StartElement("tr", ["class", "oddRow"])
> >     '<td /> is the tag for the colums
> >     ' number of <td /> elements must be the same as the number of <th
> > /> elements
> >     docXML.Element("td", "LDL Fraction")
> >     docXML.Element("td", "50 ml/dl")
> >     docXML.Element("td", "100 ml/dl")
> >     docXML.Element("td", "150 ml/dl")
> >   docXML.EndElement()
> >
> >   'On the real life you'll prefer to handle this with a Loop Control
> Structure
> >   docXML.StartElement("tr", ["class", "evenRow"])
> >     docXML.Element("td", "HDL Fraction")
> >     docXML.Element("td", "50 ml/dl")
> >     docXML.Element("td", "75 ml/dl")
> >     docXML.Element("td", "100 ml/dl")
> >   docXML.EndElement()
> >  docXML.EndElement()
> >  'PRINT Xml.EndDocument
> > END
> >
>
> emm.. ok i understand that, but I mean, I want to create xml from
tableview(gb.form), from these syntax:

TRY rso = connect.Exec("SELECT
tbl_borrow.date,tbl_borrow.id,id_journal.journal,tbl_borrow.op,tbl_borrow.pj
FROM tbl_borrow,id_journal,tbl_journal WHERE tbl_journal.id_jour=
id_journal.id AND tbl_borrow.id=tbl_journal.no_id AND tbl_borrow.id_users =
&1 AND tbl_borrow.status=1 AND tbl_borrow.code='j' ORDER BY tbl_borrow.date
DESC", rspin!id)
WITH rso
tableview3.Rows.Count = 0
IF .Count <> 0 THEN
tableview3.Columns.Count = .Fields.Count
tableview3.Rows.Count = .Count
ENDIF
END WITH

where the data result I want to exported to xml data, any suggestion, thx



More information about the User mailing list