Sign in to follow this  
Followers 0
antmar904

Reading XML File

5 posts in this topic

Hi all.

I'm having issues reading a xml file and returning the version number <rules version="467">

Here is an example of the xml file:

<rules version="467">
  <docMode>
    <domain docMode="9">site1</domain>
    <domain docMode="9">site2</domain>
    <domain docMode="8">site3</domain>
    <domain docMode="5">site4</domain>
    <domain docMode="9">site5</domain>
    <domain docMode="9">site6</domain>
  </docMode>

I am trying to get the "<rules version="467">" number 467 but when I read the file it does not return that line.

ConsoleWrite(FileRead("C:\Test\temp.xml") & @CRLF)

console output:

<docMode>
    <domain docMode="9">site1</domain>
    <domain docMode="9">site2</domain>
    <domain docMode="8">site3</domain>
    <domain docMode="5">site4</domain>
    <domain docMode="9">site5</domain>
    <domain docMode="9">site6</domain>
  </docMode>

and is missing <rules version="467">

Share this post


Link to post
Share on other sites



It works for me:

Quote

>Running:(3.3.14.2):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\LoganJ\Desktop\Test Forum Scripts.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
<rules version="467">
  <docMode>
    <domain docMode="9">site1</domain>
    <domain docMode="9">site2</domain>
    <domain docMode="8">site3</domain>
    <domain docMode="5">site4</domain>
    <domain docMode="9">site5</domain>
    <domain docMode="9">site6</domain>
  </docMode>

Are you trying to extract just the 467 number, or the whole string?


When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

just the 467.  the rules version number will be manually changed everytime the xml file is edited.

Edited by antmar904

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

$oXML = ObjCreate("Microsoft.XMLDOM")
$oXML.Load(@DesktopDir & "\test.xml")
$oNode = $oXML.selectSingleNode('//rules')
$sVersion = $oNode.getAttribute('version')
ConsoleWrite($sVersion & @CRLF)

return:

467

 

Only works when I made the XML valid:

<rules version="467">
   <docMode>
     <domain docMode="9">site1</domain>
     <domain docMode="9">site2</domain>
     <domain docMode="8">site3</domain>
     <domain docMode="5">site4</domain>
     <domain docMode="9">site5</domain>
     <domain docMode="9">site6</domain>
   </docMode> 
</rules>

 

Edited by jdelaney
1 person likes this

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.

Share this post


Link to post
Share on other sites

Thanks

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0