Dear Rao Sir ,
want to generate one .XML file from using Maridb Master detail rowsets , could you please share any example for the same. Thanks in advance..!
Thanks
Shridhar
* New Json (and Hash) support functions:
- ArrToHash( acHeader, aData )
Returns hHash with aHeader as keys and aData as values.
If aData is multi-dimensional array returns array of hashes
If acHeader is 2 dimensional array and aData is nil, first
dimension of acHeader is considered as head and second dimension
is considered as data.
- ArrToJson( acHeader, aData )
- RsToJson( oAdoRs, [nRows], [nStart], [aFields] ) --> Json Array
- FW_RecToJson( [acFields], [acNames] ) // for dbf record
- FW_DbfToJson( [cFieldList], [bFor], [bWhile], [nNext], [nRec], [lRest], [aData] )
- FW_DbfToHash( [cFieldList], [bFor], [bWhile], [nNext], [nRec], [lRest], [aData] )
- oMariaRs:RecToJson( [aFields] )
- oMariaRs:ToJson( [anRows], [nStart], [aFields] )
METHOD ToJson( anRecs, nStaPos, aFields, lwithRowNum )
METHOD ToHash( anRecs, nStaPos, aFields, lwithRowNum )
METHOD GetRows( anRecs, nStartPos, aFields, lwithRowNum )
oCn := FW_DemoDB()
cJson := oCn:States:ToJson()
oCn:Close()
[{"id":2,"CODE":"MT","NAME":"montana"},{"id":4,"CODE":"ND","NAME":"North Dakota"},{"id":5,"CODE":"SD","NAME":"South Dakota"},{"id":6,"CODE":"WY","NAME":"Wyoming"},{"id":7,"CODE":"WI","NAME":"Wisconsin A"},{"id":14,"CODE":"MA","NAME":"Massachusetts"},{"id":15,"CODE":"NE","NAME":"Nebraska hola"},{"id":16,"CODE":"NY","NAME":"New York 2"},{"id":17,"CODE":"PA","NAME":"Pennsylvania"},{"id":18,"CODE":"CT","NAME":"Connecticut"},{"id":19,"CODE":"RI","NAME":"RRRRRDIsland"},{"id":20,"CODE":"NJ","NAME":"New Jersey"},{"id":21,"CODE":"IN","NAME":"Indiana"},{"id":22,"CODE":"NV","NAME":"Nevada xxx"},{"id":23,"CODE":"UT","NAME":"Utah"},{"id":24,"CODE":"CA","NAME":"California"},{"id":25,"CODE":"OH","NAME":"Ohio"},{"id":26,"CODE":"IL","NAME":"Illinois"},{"id":27,"CODE":"DC","NAME":"District of Columbia"},{"id":28,"CODE":"DE","NAME":"Delaware Kansas"},{"id":30,"CODE":"MD","NAME":"Maryland"},{"id":31,"CODE":"CO","NAME":"Colorado"},{"id":32,"CODE":"KY","NAME":"Kentucky"},{"id":33,"CODE":"KS","NAME":"Kansas"},{"id":34,"CODE":"VA","NAME":"Virginia"},{"id":35,"CODE":"MO","NAME":"Missouri"},{"id":36,"CODE":"AZ","NAME":"Arizona"},{"id":37,"CODE":"OK","NAME":"Oklahoma"},{"id":38,"CODE":"NC","NAME":"North Carolina"},{"id":39,"CODE":"TN","NAME":"Tennessee"},{"id":40,"CODE":"TX","NAME":"Texas"},{"id":42,"CODE":"AL","NAME":"Alabama"},{"id":43,"CODE":"MS","NAME":"Mississippi"},{"id":44,"CODE":"GA","NAME":"Georgia"},{"id":45,"CODE":"SC","NAME":"South Carolina"},{"id":46,"CODE":"AR","NAME":"Arkansas"},{"id":47,"CODE":"LA","NAME":"Louisiana"},{"id":48,"CODE":"FL","NAME":"Florida"},{"id":49,"CODE":"MI","NAME":"Michigan"},{"id":50,"CODE":"HI","NAME":"SDFS"},{"id":51,"CODE":"AK","NAME":"Alaska"},{"id":52,"CODE":"CY","NAME":"Cyprus"},{"id":53,"CODE":"10","NAME":"VILIAN ARRAES"}]
Function Main()
local cJson
local hHash
local lRepeat := .T. // you have "keys" repeated
cJson := '{"states":' + cJson + "}"
oRoot := TXmlToHash():New( , , , lRepeat )
? oRoot:JsonToXml( , cJson, "myxml0.xml" )
//oRoot:End() // Not use :End(), not neccesary
Return nil
Function Main()
local cJson
local hHash
local lRepeat := .T. // you have "keys" repeated
cJson := '{"states":' + cJson + "}"
hb_JsonDecode( cJson, @hHash )
oRoot := TXmlToHash():New( , , , lRepeat )
? oRoot:HashToXml( hHash, "myxml1.xml" )
//oRoot:End() // Not use :End(), not neccesary
Return nil
METHOD End() CLASS TXmlToHash
if !Empty( ::oRoot )
MxmlDelete( ::oRoot )
endif
Return nil
<?xml version="1.0" encoding="utf-8"?>
<OTA_HotelRatePlanRS xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.opentravel.org/OTA/2003/05" xsi:schemaLocation="http://www.opentravel.org/OTA/2003/05 OTA_HotelRatePlanRS.xsd" TimeStamp="2019-09-23T15:38:16" Target="Production" Version="1.005">
<RatePlans>
<MealPlans>
<MealPlan MealPlanCode="MPT.3">
<Description>
<Text><![CDATA[Bed & Breakfast]]></Text>
</Description>
</MealPlan>
<MealPlan MealPlanCode="MPT.12">
<Description>
<Text><![CDATA[Half Board]]></Text>
</Description>
</MealPlan>
</MealPlans>
<RatePlan CurrencyCode="EUR" RatePlanCode="14500">
<Rates>
<Rate MinGuestApplicable="2" MaxGuestApplicable="2" InvTypeCode="54480" IsRoom="true" />
<Rate MinGuestApplicable="2" MaxGuestApplicable="2" InvTypeCode="54481" IsRoom="true" />
<Rate MinGuestApplicable="3" MaxGuestApplicable="3" InvTypeCode="54482" IsRoom="true" />
<Rate MinGuestApplicable="3" MaxGuestApplicable="3" InvTypeCode="54483" IsRoom="true" />
<Rate MinGuestApplicable="4" MaxGuestApplicable="4" InvTypeCode="54484" IsRoom="true" />
</Rates>
<Description>
<Text><![CDATA[Web Rate]]></Text>
</Description>
</RatePlan>
<RatePlan CurrencyCode="EUR" RatePlanCode="14501">
<Rates>
<Rate MinGuestApplicable="2" MaxGuestApplicable="2" InvTypeCode="54480" IsRoom="true" />
<Rate MinGuestApplicable="2" MaxGuestApplicable="2" InvTypeCode="54481" IsRoom="true" />
<Rate MinGuestApplicable="3" MaxGuestApplicable="3" InvTypeCode="54482" IsRoom="true" />
<Rate MinGuestApplicable="3" MaxGuestApplicable="3" InvTypeCode="54483" IsRoom="true" />
<Rate MinGuestApplicable="4" MaxGuestApplicable="4" InvTypeCode="54484" IsRoom="true" />
</Rates>
<Description>
<Text><![CDATA[Not Refundable]]></Text>
</Description>
</RatePlan>
</RatePlans>
</OTA_HotelRatePlanRS>
Maurizio wrote:Navarro ,
I have already manually encoded the XML file.
This is a test of your XMLtoHash function to see if the generated hash matches with the XML file.
In the generated HASH there are no tags like
<MealPlan MealPlanCode = "MPT.3">
Maurizio
::oRoot := MxmlLoadString( NIL, cXml, @uType_Callback() )
<![CDATA[Bed & Breakfast]]>
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 60 guests