Author | Topic: XML file generator | |
---|---|---|
Bruce Anderson | XML file generator on Tue, 20 Jan 2009 10:39:23 -0600 Is there a XML creation app which can build a file from dbfs? Is this the right newsgroup for this question? | |
Thomas Braun | Re: XML file generator on Fri, 23 Jan 2009 09:17:32 +0100 Bruce Anderson wrote: > Is there a XML creation app which can build a file from dbfs? Basically, an XML file is a text file, so building a XML from a dbf is a DO WHILE ! EOF()...ENDDO -Loop with a few string processing functions inbetween. Here are a few methods that basically do the job, just to get an impression: METHOD Base:GetXMLRec(lEncode) LOCAL cRet, nI DEFAULT lEncode TO .F. cRet := '<record id="' + ALLTRIM(FIELD->ID) + '">' FOR nI := 1 TO FCOUNT() cRet += XmlField(Fieldname(nI),,, lEncode) NEXT cRet += "</record>" RETURN cRet FUNCTION XmlField( xField, cTAG, cAlias, lEncode, bCOnvert ) LOCAL cRet := "<" LOCAL nField, nPos DEFAULT xField TO "" DEFAULT cAlias TO ALIAS() DEFAULT lEncode TO .F. IF ! EMPTY(xField) IF VALTYPE(xField) = "C" Fieldname IF (nPos := AT("->", xField)) > 0 cAlias := SUBSTR(xField, 1, nPos-1) xField := SUBSTR(xField, nPos+2) ENDIF nField := (cAlias)->(FIELDPOS(xField)) ELSEIF VALTYPE(xField) = "N" nField := xField xField := FIELDNAME(xField) ENDIF DEFAULT cTAG TO xField cRet += cTAG IF bConvert = NIL xField := ALLTRIM(XtoC( (cAlias)->(FIELDGET(nField)) )) ELSE xField := ALLTRIM(EVAL(bConvert, (cAlias)->(FIELDGET(nField)) )) ENDIF IF lEncode xField := XMLEncode(xField) ENDIF IF EMPTY(xField) cRet += "/>" ELSE cRet += ">" + xField + "</" + cTAG + ">" ENDIF ENDIF RETURN cRet regards Thomas | |
Bruce Anderson | Re: XML file generator on Fri, 23 Jan 2009 10:00:22 -0600 Yes, I understand this. I was wondering if there is an existing app which takes a relational dbf set and creates the XML from it, i.e., something more than a flat file. Example: a customer list with zero to many invoices for each customer. I think I will have to break down and write this. I was hoping this time I could skip some of the fun of creation. Bruce Anderson Graphical Database Programs Houston, TX | |
Thomas Braun | Re: XML file generator on Fri, 23 Jan 2009 17:59:13 +0100 Bruce Anderson wrote: > Yes, I understand this. I was wondering if there is an existing app which > takes a relational dbf set and creates the XML from it, i.e., something more > than a flat file. Example: a customer list with zero to many invoices for > each customer. I wonder how a generic solution for such a type of problem could look like. There is not only one "correct" way to transform a DBF file into a xml file... > I think I will have to break down and write this. I was > hoping this time I could skip some of the fun of creation. naahhhh Thomas | |
JAYARAM MYSORE | Re: XML file generator on Sat, 30 Jan 2010 05:59:26 +0530 I found this DBF browser and I like it very much. This can Convert DBF to XML in command line. http://www.dbf2002.com/ Regards Jayaram "Bruce Anderson" <banderson@graphical-db.com> wrote in message news:392bd0d4$2d2c12c9$9a1@news.alaska-software.com... > Is there a XML creation app which can build a file from dbfs? > Is this the right newsgroup for this question? > |