Gobinath Posted July 2, 2011 Posted July 2, 2011 <BackupSet> <Name>07-02-2011_12-43-34</Name> <OSVersion>Windows7</OSVersion> <CreationTime>07/02/2011 12:44:06</CreationTime> <DiskSize>40.0 GB</DiskSize> <DiskUsedSize>40.0 GB</DiskUsedSize> <BackupType>PARTITION_BACKUP</BackupType> <CompressionType>NO_COMPRESSION</CompressionType> <EncryptionType>NO_ENCRYPTION</EncryptionType> <Comment></Comment> <MaxNoOfIncrementals>600</MaxNoOfIncrementals> <VolumeSet>G,I</VolumeSet> <NoOfPartitions>2</NoOfPartitions> <Partition> <Name>G:\</Name> <Index></Index> <Size>20.0 GB</Size> <UsedSpace>1.53 GB</UsedSpace> </Partition> <Partition> <Name>I:\</Name> <Index></Index> <Size>19.99 GB</Size> <UsedSpace>202.13 MB</UsedSpace> </Partition> </BackupSet>here i m using this xml file how to read the name (which is bold) Exactlyand store in to variable ????????????backupsetinfo1.xml
taietel Posted July 2, 2011 Posted July 2, 2011 #include <Array.au3> $hXML = FileOpen(@ScriptDir & "\backupsetinfo1.xml") If $hXML = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $sXML = FileRead($hXML) FileClose($hXML) $aRet = StringRegExp($sXML, '<Name>(.*?)</Name>', 3) _ArrayDisplay($aRet) Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text
Malkey Posted July 2, 2011 Posted July 2, 2011 This example is a little bit more tailored to the .xml file in post #1. The reg. exp. pattern excludes matches having ":" present in between "<Name>" and "</Name>". #include <Array.au3> Local $sXML = FileRead(@ScriptDir & "\backupsetinfo1.xml") Local $aRet = StringRegExp($sXML, '<Name>([^:]*?)</Name>', 3) _ArrayDisplay($aRet)
Fubarable Posted July 2, 2011 Posted July 2, 2011 Myself, I'd do this with Java and its XPath library which are excellent tools for this type of job.
taietel Posted July 2, 2011 Posted July 2, 2011 If there are many attributes in the xml, I use eltorro's XML Dom Wrapper but for this it's easier to use SRE. Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text
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