BrandNewTester Posted August 21, 2012 Posted August 21, 2012 Hi all..I m traying to read contents from the xml file.xml file tags are repeated..I have pasted my xml file below..plz any one help me...aaa.xml <?xml version="1.0" encoding="utf-8" ?>- <node xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.alpan.com/nodes/ws/"> <id>###################################</id> <hasLogs>true</hasLogs>- <hints> <objectStorageId xmlns="http://schemas.alpan.com/utility/ws/">0</objectStorageId>- <hints>- <hint> <First xmlns="http://schemas.alpan.com/utility/ws/">Isdirected</First> <Second xmlns="http://schemas.alpan.com/utility/ws/">True</Second> </hint>- <hint> <First xmlns="http://schemas.alpan.com/utility/ws/">CanBeMonitored</First> <Second xmlns="http://schemas.alpan.com/utility/ws/">True</Second> </hint>- <hint> <First xmlns="http://schemas.alpan.com/utility/ws/">MachineSmbiosId</First> <Second xmlns="http://schemas.alpan.com/utility/ws/">##################</Second> </hint>- <hint> <First xmlns="http://schemas.alpan.com/utility/ws/">MachineAddress</First> <Second xmlns="http://schemas.alpan.com/utility/ws/">###################</Second> </hint>- <hint> <First xmlns="http://schemas.alpan.com/utility/ws/">MachineType</First> <Second xmlns="http://schemas.alpan.com/utility/ws/">#################</Second> </hint>- <hint> <First xmlns="http://schemas.alpan.com/utility/ws/">MachineVersionMajor</First> <Second xmlns="http://schemas.alpan.com/utility/ws/">############</Second> </hint>- <hint> <First xmlns="http://schemas.alpan.com/utility/ws/">MachineOSEdition</First> <Second xmlns="http://schemas.alpan.com/utility/ws/">###################</Second> </hint>- <hint> <First xmlns="http://schemas.alpan.com/utility/ws/">SiteId</First> <Second xmlns="http://schemas.alpan.com/utility/ws/">#######################</Second> </hint>- <hint> <First xmlns="http://schemas.alpan.com/utility/ws/">Credential</First> <Second xmlns="http://schemas.alpan.com/utility/ws/">#########################</Second> </hint> </hints> </hints> <detailsName>sles9</detailsName> <detailsType>alpan.RemoteInventory.Sdk.Api.Schemas.Machines.Contained.VMwareESXVirtualMachine</detailsType> <detailsUrl>IInventoryRepo.Servic</detailsUrl>- <imageResource> <id xmlns="http://schemas.alpan.com/resources/ws/">#################</id> </imageResource> <existence>aaaaaaaaaa</existence> </node>In this xml file,I required values like...MachineSmbiosIdMachineTypeMachineAddressMachineMajorVersionMachineOsEditionHow to get these values..please any one help me .........thanks in advance.........BNT
stormbreaker Posted August 21, 2012 Posted August 21, 2012 Perhaps, this could help you get started: Good luckRegards... ---------------------------------------- :bye: Hey there, was I helpful? ---------------------------------------- My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1
BrandNewTester Posted August 21, 2012 Author Posted August 21, 2012 Hi MKISH Thanks for replay.... I could work on that.But failed to get the values..... my xml file have repeated fields...
jdelaney Posted August 21, 2012 Posted August 21, 2012 (edited) Load in the xml, use the xpath of the repeated node you want, and then do a loop to an array, or a loop to whatever you need of it: $stest being your XML file, and whatever your legit xpath is in the selectnodes() $oXML=ObjCreate("Microsoft.XMLDOM") $oXML.load($stest) ; load document $result = $oXML.selectNodes( '//First' ) For $Node In $result consolewrite($Node.text & @crlf ) Next Edited August 21, 2012 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
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