SummerGirl Posted July 11, 2013 Posted July 11, 2013 Dear all, Need some help with extracting the values from xml file. I am newbee...and want some help. I want to extract all the TotalStudyTime for every student 1,2 and output to a particular cell in Excel Please let me know how to proceed. I browsed _XMLDomWrapper.au3 but please let me know where I can download and how to use them to extract attibute. Thanks in advance. My XML file:(StudentTime.xml) <?xml version="1.0" encoding="utf-8"?> <StudyTime> <Student Name="1" TopGrade="False"> <Class10> <Physics> <StudyTime="4" ExperimentTime="1" /> </Physics> <Chemistry> <StudyTime="3" ExperimentTime="3" /> </Chemistry> <Total> < PhysicsTotalTime="5" ChemistryTotalTime="6" TotalStudyTime="11"/> </Total> </Class10> </Student> <Student Name="2" TopGrade="False"> <Class10> <Physics> <StudyTime="5" ExperimentTime="1" /> </Physics> <Chemistry> <StudyTime="5" ExperimentTime="3" /> </Chemistry> <Total> < PhysicsTotalTime="6" ChemistryTotalTime="8" TotalStudyTime="14"/> </Total> </Class10> </Student> </StudyTime>
Jury Posted July 16, 2013 Posted July 16, 2013 (edited) If no one else is going to help - try this for a start: #include <Array.au3> Local $file = FileOpen("StudentTime.xml", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $XML = FileRead($file) $array = StringRegExp($XML, '(?i)(?-s)<Student Name="(.*?)"(?s).*?(?s)TotalStudyTime="(\d+)', 3) _ArrayDisplay($array, 1) FileClose($file) of course you'll have to put the directory path to your file or use _INetGetSource to grab the data - now you've got the data you can try out the various options for keeping it Excel etc. Edited July 17, 2013 by Jury
water Posted July 16, 2013 Posted July 16, 2013 I browsed _XMLDomWrapper.au3 but please let me know where I can download and how to use them to extract attibute. What do you mean by "download"? If you browsed the UDF then you already did a download. Most of the time you find a UDF on the first post of a thread. In this case >here. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now