rakeshreddy42
asked on
Any one explain how to read data from xml file and store that data in to an excel sheet
Hi experts,
How to read a xml file and read the data in xml in to an excel sheet??
How to read a xml file and read the data in xml in to an excel sheet??
You might be able to use the XML::Simple module. This makes it very easy to read the XML file, but you don't get quite as much control over how it is read. Whether it works will depend on your specific requirements.
Writing to a csv file would be easiest, and excel will be able to read it. If you need more control over the output, you can use Spreadsheet::WriteExcel.
Writing to a csv file would be easiest, and excel will be able to read it. If you need more control over the output, you can use Spreadsheet::WriteExcel.
ASKER
Hi Adam,
could you give a smple script for reading an xml file into an csv file or an excel sheet.
say the sml file is as below.
<architectures>
<architecture>
<name>Pace5</name>
<testcases>
<testcase>tc_arm_icache<te stcase>
<cache>
<icache_size>32K</icache_s ize>
<dcache_size>4K</dcache_si ze>
</cache>
<testcase>tc_arm_idcache<t estcase>
<cache>
<icache_size>32K</icache_s ize>
<dcache_size>32K</dcache_s ize>
</cache>
<testcase>tc_arm_idcache<t estcase>
<cache>
<icache_size>32K</icache_s ize>
<dcache_size>4K</dcache_si ze>
</cache>
</testcases>
</architecture>
<architecture>
<name>Faraday</name>
<testcases>
<testcase>tc_arm_dcache<te stcase>
<cache>
<icache_size>16K</icache_s ize>
<dcache_size>4K</dcache_si ze>
</cache>
<testcase>tc_arm_icache<te stcase>
<cache>
<icache_size>4K</icache_si ze>
<dcache_size>16K</dcache_s ize>
</cache>
</testcases>
</architecture>
</architectures>
Thanks & Regards,
Rakesh.
could you give a smple script for reading an xml file into an csv file or an excel sheet.
say the sml file is as below.
<architectures>
<architecture>
<name>Pace5</name>
<testcases>
<testcase>tc_arm_icache<te
<cache>
<icache_size>32K</icache_s
<dcache_size>4K</dcache_si
</cache>
<testcase>tc_arm_idcache<t
<cache>
<icache_size>32K</icache_s
<dcache_size>32K</dcache_s
</cache>
<testcase>tc_arm_idcache<t
<cache>
<icache_size>32K</icache_s
<dcache_size>4K</dcache_si
</cache>
</testcases>
</architecture>
<architecture>
<name>Faraday</name>
<testcases>
<testcase>tc_arm_dcache<te
<cache>
<icache_size>16K</icache_s
<dcache_size>4K</dcache_si
</cache>
<testcase>tc_arm_icache<te
<cache>
<icache_size>4K</icache_si
<dcache_size>16K</dcache_s
</cache>
</testcases>
</architecture>
</architectures>
Thanks & Regards,
Rakesh.
How do you want that to become a CSV file. Post an example of the desired output.
ASKER
hi adam,
the output should be as below.Along with the above xml file we have to read data from another xml file:
File2.xml
<testcase>
<number>tc_arm_icache</num ber>
<use>Yes</use>
</testcase>
<testcase>
<number>tc_arm_dcache</num ber>
<use>Yes</use>
</testcase>
<testcase>
<number>tc_arm_idcache</nu mber>
<use>Yes</use>
</testcase>
<testcase>
<number>tc_arm_idcache</nu mber>
<use>Yes</use>
</testcase>
<testcase>
<number>tc_arm_icache</num ber>
<use>Yes</use>
</testcase>
Read above xml files and arrange the read information (with appropriate conversion, such as converting 32K to 32768) in an excel sheet named, TestInformaiton.xls, in following format.
Test Case No. Architecture Cache Usable
ICache Size DCache Size
tc_arm9_icache Pace5 32768 4096 Yes
tc_arm9_dcache Faraday 16384 4096 No
tc_arm9_idcache Pace5 32768 32768 Yes
tc_arm9_idcache Pace5 32768 4096 Yes
tc_arm9_icache Faraday 4096 16384 Yes
Thanjks,
Rakesh.
the output should be as below.Along with the above xml file we have to read data from another xml file:
File2.xml
<testcase>
<number>tc_arm_icache</num
<use>Yes</use>
</testcase>
<testcase>
<number>tc_arm_dcache</num
<use>Yes</use>
</testcase>
<testcase>
<number>tc_arm_idcache</nu
<use>Yes</use>
</testcase>
<testcase>
<number>tc_arm_idcache</nu
<use>Yes</use>
</testcase>
<testcase>
<number>tc_arm_icache</num
<use>Yes</use>
</testcase>
Read above xml files and arrange the read information (with appropriate conversion, such as converting 32K to 32768) in an excel sheet named, TestInformaiton.xls, in following format.
Test Case No. Architecture Cache Usable
ICache Size DCache Size
tc_arm9_icache Pace5 32768 4096 Yes
tc_arm9_dcache Faraday 16384 4096 No
tc_arm9_idcache Pace5 32768 32768 Yes
tc_arm9_idcache Pace5 32768 4096 Yes
tc_arm9_icache Faraday 4096 16384 Yes
Thanjks,
Rakesh.
How do you match data between two files?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://search.cpan.org/dist/XML-LibXML/ explains the packages in XML::LibXML (pay attention to the Documentation links for Document and Element)
GO through and read the nodes in your XML file, and construct a CSV file. You can then read (import) the file in excel