Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have a field in one of my database tables which consists of a piece of XML. The table itself is a list of currencies, and the XML field is labelled 'exchange_rate' which consists of exchange rates from the currency of the current row into all other countries. Here is an example of the XML contained within just one of these fields, the following is an example of the 'exchage_rate' field for the currency with name 'EUR':
<to-currency csymbol="EUR" cname="Euro" base-exchange-rate="1.3162405881282215">
<currency id="8">
<csymbol>AUD</csymbol>
<cname>Australia Dollars</cname>
<crate>1.2235024</crate>
</currency>
<currency id="4">
<csymbol>CAD</csymbol>
<cname>Canada Dollars</cname>
<crate>1.3100298</crate>
</currency>
<currency id="6">
<csymbol>CNY</csymbol>
<cname>China Yuan Renminbi</cname>
<crate>8.2902755</crate>
</currency>
<currency id="3">
<csymbol>GBP</csymbol>
<cname>United Kingdom Pounds</cname>
<crate>0.8392476</crate>
</currency>
<currency id="9">
<csymbol>HKD</csymbol>
<cname>Hong Kong Dollars</cname>
<crate>10.2056222</crate>
</currency>
<currency id="5">
<csymbol>IDR</csymbol>
<cname>Indonesia Rupiahs</cname>
<crate>11898.8149167</crate>
</currency>
<currency id="7">
<csymbol>JPY</csymbol>
<cname>Japan Yen</cname>
<crate>103.275566</crate>
</currency>
<currency id="1">
<csymbol>USD</csymbol>
<cname>United States Dollars</cname>
<crate>1.3162406</crate>
</currency>
</to-currency>
Is there a way to parse this data in the Qlikview load script so that it is easily accessible in a table in my Qlikview document?
Thanks,
Peter
HI ,
Try the attach application.
Go to tablefile (in script). Select xml from the file type. A wizard will appear. On the left select Xml and click on Finish.
I hope this what you are looking for.
Deepak
Thanks for your reply,
I'm not sure this solution will work, as the XML I attached is just one entry in an existing table in the database, it is not contained in an external XML file (such as 01.xml in your example).
Is there a way I can parse XML which is contained within a field in the database?
Thanks again,
Peter
hi Peter,
Try storing the Data into xml.
Eg:
Test:
Load * from table.
Store Test into Test.xml;
I am assuming you have only one row. If you have multiple you need to take only the required row.
ONce you have the XML use like the above method.
Deepak
Hi Deepak,
I still have not managed to get this working.
Let me paste in some examples....
The following is what appears in my load script:
currency_xml:
LOAD `exchange_rate`;
SQL SELECT *
FROM `prod`.`currency` WHERE `currency_id`='1';
STORE currency_xml into Test.xml;
This loads the 'exchange_rate' field for the first entry in the 'currency' table. This field contains the following data:
<to-currency csymbol="USD" cname="United States Dollars" base-exchange-rate="1.0">
<currency id="8">
<csymbol>AUD</csymbol>
<cname>Australia Dollars</cname>
<crate>0.9294792</crate>
</currency>
<currency id="4">
<csymbol>CAD</csymbol>
<cname>Canada Dollars</cname>
<crate>0.9935059</crate>
</currency>
<currency id="6">
<csymbol>CNY</csymbol>
<cname>China Yuan Renminbi</cname>
<crate>6.2944602</crate>
</currency>
<currency id="2">
<csymbol>EUR</csymbol>
<cname>Euro</cname>
<crate>0.7550288</crate>
</currency>
<currency id="3">
<csymbol>GBP</csymbol>
<cname>United Kingdom Pounds</cname>
<crate>0.6308323</crate>
</currency>
<currency id="9">
<csymbol>HKD</csymbol>
<cname>Hong Kong Dollars</cname>
<crate>7.7547209</crate>
</currency>
<currency id="5">
<csymbol>IDR</csymbol>
<cname>Indonesia Rupiahs</cname>
<crate>8990.0000026</crate>
</currency>
<currency id="7">
<csymbol>JPY</csymbol>
<cname>Japan Yen</cname>
<crate>79.4669123</crate>
</currency>
</to-currency>
However, when I look at the Test.xml file which the load script produces, I see the following:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<QvdTableHeader>
<QvBuildNo>9061</QvBuildNo>
<CreatorDoc>C:\QlikView\Production\Sources\QVDs\Create_prod_QVDs.qvw</CreatorDoc>
<CreateUtcTime>2012-02-23 14:58:38</CreateUtcTime>
<SourceCreateUtcTime></SourceCreateUtcTime>
<SourceFileUtcTime></SourceFileUtcTime>
<SourceFileSize>-1</SourceFileSize>
<StaleUtcTime></StaleUtcTime>
<TableName>currency_xml</TableName>
<Fields>
<QvdFieldHeader>
<FieldName>exchange_rate</FieldName>
<BitOffset>0</BitOffset>
<BitWidth>8</BitWidth>
<Bias>0</Bias>
<NumberFormat>
<Type>UNKNOWN</Type>
<nDec>0</nDec>
<UseThou>0</UseThou>
<Fmt></Fmt>
<Dec></Dec>
<Thou></Thou>
</NumberFormat>
<NoOfSymbols>1</NoOfSymbols>
<Offset>0</Offset>
<Length>1132</Length>
<Comment></Comment>
<Tags></Tags>
</QvdFieldHeader>
</Fields>
<Compression></Compression>
<RecordByteSize>1</RecordByteSize>
<NoOfRecords>1</NoOfRecords>
<Offset>1132</Offset>
<Length>1</Length>
<Lineage>
<LineageInfo>
<Discriminator>ODBC;DSN=prod2</Discriminator>
<Statement>SQL SELECT *
FROM `prod`.`currency`</Statement>
</LineageInfo>
<LineageInfo>
<Discriminator>ODBC;DSN=prod2</Discriminator>
<Statement>SQL SELECT *
FROM `prod`.`currency` WHERE `currency_id`='1'</Statement>
</LineageInfo>
<LineageInfo>
<Discriminator>ODBC;DSN=prod2</Discriminator>
<Statement>currency:
LOAD `currency_id`,
`short_name`,
`full_name`,
`exchange_rate`,
created,
`last_update`,
`created_by`,
`last_updated_by`,
status;SQL SELECT *
FROM `prod`.`currency`</Statement>
</LineageInfo>
<LineageInfo>
<Discriminator>ODBC;DSN=mb_prod2</Discriminator>
<Statement>currency_xml:
LOAD `exchange_rate`;SQL SELECT *
FROM `prod`.`mb_currency` WHERE `currency_id`='1'</Statement>
</LineageInfo>
</Lineage>
<Comment></Comment>
</QvdTableHeader>
<to-currency csymbol="USD" cname="United States Dollars" base-exchange-rate="1.0">
<currency id="8">
<csymbol>AUD</csymbol>
<cname>Australia Dollars</cname>
<crate>0.9294792</crate>
</currency>
<currency id="4">
<csymbol>CAD</csymbol>
<cname>Canada Dollars</cname>
<crate>0.9935059</crate>
</currency>
<currency id="6">
<csymbol>CNY</csymbol>
<cname>China Yuan Renminbi</cname>
<crate>6.2944602</crate>
</currency>
<currency id="2">
<csymbol>EUR</csymbol>
<cname>Euro</cname>
<crate>0.7550288</crate>
</currency>
<currency id="3">
<csymbol>GBP</csymbol>
<cname>United Kingdom Pounds</cname>
<crate>0.6308323</crate>
</currency>
<currency id="9">
<csymbol>HKD</csymbol>
<cname>Hong Kong Dollars</cname>
<crate>7.7547209</crate>
</currency>
<currency id="5">
<csymbol>IDR</csymbol>
<cname>Indonesia Rupiahs</cname>
<crate>8990.0000026</crate>
</currency>
<currency id="7">
<csymbol>JPY</csymbol>
<cname>Japan Yen</cname>
<crate>79.4669123</crate>
</currency>
</to-currency>
Consequently, when I go to my Qlikview document and try and load the xml file via the 'Table files...' button, it thinks the XML ends after the </QvdTableHeader> tag and does not allow me to load the data that I am actually interested in.
Is there a way to save only the XML contained within the database filed into the Test.xml file without all of the associated metadata?
Thanks again,
Peter
Hi Peter,
I used macro to convert the data into xml. This xml can then be read by qlikview.
Please check the attach file.
Deepak
Hi Penfold,
I am also looking for some similar kind of solution...Can you please let me know if you did solve it out?
Thanks,
Sujith.
Hi Sujith,
Try the attach application.
Regards
Deepak
Hi Deepak,
Thanks for your help,this is what exactly what i was looking for,but my question here is how and where did you get the data into tables Data-1 and Data-2? How did you load them from the sql table?Can you please explain me in detail.
Thanks,
Sujith.