Jump to content

XMLWrapper & Microsoft.XMLDOM


Recommended Posts

I want to read some infos from a XML File.

I have fount here the XML Wrapper but it seems there is nor further development.

I have found here some code

Local $Str = '<update xmlns="http://ns.adobe.com/air/framework/update/description/2.5"><versionNumber>7.0.215</versionNumber></update>'
$oXML = ObjCreate("Microsoft.XMLDOM")
$oXML.loadXML($Str)
$oNode=$oXML.SelectSingleNode('/update/versionNumber')
ConsoleWrite($oNode.text & @CRLF)

Is the Microsoft.XMLDOM usable in Autoit?

 

Link to post
Share on other sites

Yes, it is. Here is an example where JDelaney uses it to create an excel file: >link

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to post
Share on other sites

Nice, so I can use all this stuff here?

http://msdn.microsoft.com/en-us/library/ms757828(v=vs.85).aspx

 

Yep :D

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to post
Share on other sites

I have a database xml file from xbmc, maybe some of you know this file.

I this file, there are all movies and tv series.

I want to use autoit to select some infos from this file and make a little list for a quick overview.

I would like to have a list with the name of the series for example "Dexter".

Next I would select the number of the seasons from it, for example "Season 1", "Season 2", "Season 5"

A highlight would be if it is possible to show the number of episodes from each season, for example "Season 1 (12 episodes)", Season 2 (16 episodes) etc.

Here you can find an example file of the database

https://www.dropbox.com/s/j5i5sczr90bkxdb/videodb_ex.xml?dl=0

Link to post
Share on other sites

Provide a small sample of the xml, here.  I'd prefer to not need to download.

Here is a small example...you can easily create a gui, and construct the xpaths from the values you need:

$oXML = ObjCreate("Microsoft.XMLDOM")
; use load to load in an XML file
$oXML.loadxml("<all><show ID='dexter'><season ID='1'><episode ID='1'/><episode ID='2'/></season><season ID='2'><episode ID='1'/><episode ID='2'/></season><season ID='3'><episode ID='1'/><episode ID='2'/><episode ID='3'/></season></show></all>")
$oDexter = $oXML.selectsinglenode("//show[@ID='dexter']")

;~ ; example of picking season 1 and 3
$oSelectedSeasons = $oDexter.selectnodes("./season[@ID='1']|./season[@ID='3']")

; outputing the counts of episodes
For $oSeason In $oSelectedSeasons
    $oEpisodes = $oSeason.selectnodes("./episode")
    ConsoleWrite($oSeason.getattribute("ID") & " " & $oEpisodes.length & @CRLF)
Next

This works too:

$oSelectedSeasons = $oDexter.selectnodes("./season[@ID='1' or @ID='3']")
$oSelectedSeasons = $oXML.selectnodes("//show[@ID='dexter']/season[@ID='1' or @ID='3']")

diff shows:

$oSelectedSeasons = $oXML.selectnodes("//show[@ID='dexter']/season[@ID='1' or @ID='3']|//show[@ID='somethingelse]/season[@ID='2']")
Edited 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.
Link to post
Share on other sites

Thanks for the code but still too complicated to me.

Hope you can teach me again a little bit more.

I made a small xml file, so you can see how the structure is. Should be the same like the big file but only with the values I need.

From this xml file it would be interesting to get a list with the names of the tvshows, for example Bones, Burn Notice, Californication...

From these names/shows I would like to get the info how many seasons per show are found, for example Bones season 1, Burn Notice Season 1, 2 and 3 and Californication 1

Is there another way than console write to handle the results, tried MsBox and _ArrayDisplay, but no success. :-(

 

Here the small xml file

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<videodb>
    <tvshow>
        <title>Bones</title>
        <showtitle>Bones</showtitle>
        <year>2005</year>
        <episode>22</episode>
        <episodedetails>
            <title>Die Frau im Teich</title>
            <showtitle>Bones</showtitle>
            <season>1</season>
            <episode>1</episode>
        </episodedetails>
        <episodedetails>
            <title>Der Mann im Jeep</title>
            <showtitle>Bones</showtitle>
            <season>1</season>
            <episode>2</episode>
        </episodedetails>
        <episodedetails>
            <title>Der Junge am Baum</title>
            <showtitle>Bones</showtitle>
            <season>1</season>
            <episode>3</episode>
        </episodedetails>
    </tvshow>

    <tvshow>
        <title>Burn Notice</title>
        <showtitle>Burn Notice</showtitle>
        <episode>44</episode>
        <episodedetails>
            <title>Kaltgestellt</title>
            <showtitle>Burn Notice</showtitle>
            <season>1</season>
            <episode>1</episode>
        </episodedetails>
        <episodedetails>
            <title>Die Rivalin</title>
            <showtitle>Burn Notice</showtitle>
            <season>2</season>
            <episode>15</episode>
        </episodedetails>
        <episodedetails>
            <title>Explosiv</title>
            <showtitle>Burn Notice</showtitle>
            <season>3</season>
            <episode>16</episode>
        </episodedetails>
    </tvshow>

    <tvshow>
        <title>Californication</title>
        <showtitle>Californication</showtitle>
        <episode>36</episode>
        <episodedetails>
            <title>Verhängnisvolle Affäre</title>
            <showtitle>Californication</showtitle>
            <season>1</season>
            <episode>1</episode>
        </episodedetails>
    </tvshow>   
</videodb>
Link to post
Share on other sites

Basics here...you need to add gui logic to grab additional data based on the list selection...maybe make a button to do so, or something

;~$hWnd = _GUICtrlListBox_Create

$oXML = ObjCreate("Microsoft.XMLDOM")
$oXML.load("yourXMLFile.xml")
$oShows = $oXML.selectNodes("//tvshow/showtitle")
For $oShow In $oShows

;~  _GUICtrlListBox_AddString($hWnd, $oShow.text)
    ConsoleWrite($oShow.text & @CRLF)
Next
Edited 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.
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...