Sign in to follow this  
Followers 0
dynamitemedia

Reading XML into listview

5 posts in this topic

#1 ·  Posted (edited)

Ok So i started using autoit and love it i was using zenity for windows and still plan on using for some things cause have no idea how to change all my bat files over to auto it, lol...

so my 1st question tonight is loading the list views... i have created a gui front end for ffmpeg and so far its got the "look" i want lol.

so i have xml that looks like this

<channel ID='2' url='http://videe.com/index.php/channel/3a9a071' name='Guest1588664 live from Android' quality='best'/> 
<channel ID='3' url='http://videe.com/index.php/channel/ea579cc92d' name='boulon live' quality='best'/> 
<channel ID='4' url='http://videe.com/index.php/channel/290a3a52b' name='frank11262' quality='best'/> 
<channel ID='5' url='http://videe.com/index.php/channel/ab6c066e' name='REAL MADRID  #  LIVERPOOL 19:45 gmt' quality='best'/> 

Step One:
i want to pull this into List view by the node "name"

Step Two:
when i click on a button say "Watch" it saves the info to my streamSettings.ini that looks like this if i click on "frank11262"

 

i have buttons on bottom and would like to update protocol=Watch using the label of the button pushed so in this case "watch"  I also need this to launch watch.exe  so it saves to stream settings and then launches an external exe i built in batch

#Name of video
name=frank11262

#URL of video for Live streamer
URL=http://videe.com/index.php/channel/290a3a52bl

#quality of video for Live streamer 
quality=best

#Video Streaming Protocol
protocol=Watch

my code i have now for this Tab looks like this:
 

; --------------   Channel Guide Tab --------------


$plugins = GUICtrlCreateTab(8, 8, 580, 336)
$Guide = GUICtrlCreateTabItem("Channel Guide ")


; Need to open XML to display
$Button10 = GUICtrlCreateButton("Open XML", 32, 56, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")


; Refreshes the XML opened up 
$Button12 = GUICtrlCreateButton("Refresh", 120, 56, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")


; add the XML from above 
$List1 = GUICtrlCreateList("", 31, 89, 529, 230)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
Edited by dynamitemedia

Share this post


Link to post
Share on other sites



i found the way to launch the ex files and input forms and save to tex but still stuck on the xml... i found this but doesnt work with the way my xml is written or getting back from the server

here is snippet i found

; Simple Way Of Parsing XML Data.
 
#include <Array.au3>
 
Global $aReturn, $sXMLData
 
$sXMLData = "<data>This is a Simple example of XML</data><data>This is a Simple example of XML and is the Second String.</data>"
$aReturn = _GetXML($sXMLData, "data")
_ArrayDisplay($aReturn, "_GetXML()")
 
Func _GetXML($sString, $sData)
Local $aError[2] = [1, $sString], $aReturn
$aReturn = StringRegExp('<' & $sData & '></' & $sData & '>' & $sString, '(?s)(?i)<' & $sData & '>(.*?)</' & $sData & '>', 3)
If @error Then
Return SetError(1, 0, $aError)
EndIf
$aReturn[0] = UBound($aReturn, 1) - 1
Return SetError(0, 0, $aReturn)
EndFunc ;==>_GetXML

the xml i get back looks like this once again

<channel ID='2' url='http://videe.com/index.php/channel/3a9a071' name='Guest1588664 live from Android' quality='best'/>

i am ok with ID and name being shown but prefer not the URL or Quality seems like it is too messy.

i have found plenty of how to save to xml but i just need ito get it in and then save out the line i click the button after i select the line i want.

Share this post


Link to post
Share on other sites

 

so i have xml that looks like this

<channel ID='2' url='http://videe.com/index.php/channel/3a9a071' name='Guest1588664 live from Android' quality='best'/> 
<channel ID='3' url='http://videe.com/index.php/channel/ea579cc92d' name='boulon live' quality='best'/> 
<channel ID='4' url='http://videe.com/index.php/channel/290a3a52b' name='frank11262' quality='best'/> 
<channel ID='5' url='http://videe.com/index.php/channel/ab6c066e' name='REAL MADRID  #  LIVERPOOL 19:45 gmt' quality='best'/> 

 

This looks more like HTML than XML, which is probably why your attempts to parse the data are failing.

Share this post


Link to post
Share on other sites

Ok well i got this working but i still need to figure out a better way to get the button to load the xml

$plugins = GUICtrlCreateTab(8, 8, 580, 336)
$Guide = GUICtrlCreateTabItem("Channel Guide ")

; Need to open XML to display
$Button10 = GUICtrlCreateButton("Open XML", 32, 56, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")

; Refreshes the XML opened up 
$Button12 = GUICtrlCreateButton("Refresh", 120, 56, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")


; add the XML from above 
$oOXml = @ScriptDir & "\listings\video.xml"
$sRead = FileRead($oOXml)


$aGroup = StringRegExp($sRead, "(?i)ID='(.*?)'", 3)
$aItem = StringRegExp($sRead, "(?i)name='(.*?)'", 3)
$iUbound = UBound($aGroup)
If UBound($aItem) > $iUbound Then $iUbound = UBound($aItem)


$List1 = GUICtrlCreateListView("ID|Name", 31, 89, 529, 230)


For $i = 0 To $iUbound - 1
$strData = ""
If UBound($aGroup) > $i Then $strData &= $aGroup[$i]
If UBound($aItem) > $i Then $strData &= "|" & $aItem[$i]
_GUICtrlListView_SetColumnWidth($List1, 0, 40)
_GUICtrlListView_SetColumnWidth($List1, 1, 440)
GUICtrlCreateListViewItem($strData, $List1)
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
Next

How do i use those buttons  to load the xml?  i have tried:

Case $MSG = $Button10 ; Need to open XML to display
FileOpenDialog("", @ScriptDir & "\listings", "XML (*.xml)", 1)
If @error Then
MsgBox(4096, "File Open", "No file chosen")
;Exit
Else
$oOXml = ""
$oOXml = _XMLFileOpen ($sXmlFile)
MsgBox(0, "Iy v2.0", "opened xml!")
EndIf

 But i can not figure out how to start with one XML like  above BUT change it on the open or refresh XML buttons

Share this post


Link to post
Share on other sites

OK to help anyone out who ever comes across this and PLEASE  fix if anyone knows a better way  i have only been using autoit for about 2 days

when the button "open" is clicked this will be the action to load the XML

Case $MSG = $Button10 ; Need to open XML to display 

$openXML = FileOpenDialog("Choose a file", @ScriptDir & "\listings", "XML (*.xml)", 1 + 4 )
If @error Then
MsgBox(0,"IpTvMyWay v2.0","No File(s) chosen")
Else
$openXML = StringReplace($openXML, "|", @CRLF)

MsgBox(0,"","You chose " & $openXML)
_GUICtrlListView_DeleteAllItems($List1)
$sRead = FileRead($openXML)

Local $aID = StringRegExp($sRead, "(?i)ID='(.*?)'", 3)
Local $aName = StringRegExp($sRead, "(?i)name='(.*?)'", 3)
Local $aQuality= StringRegExp($sRead, "(?i)quality='(.*?)'", 3)
Local $aUrl= StringRegExp($sRead, "(?i)url='(.*?)'", 3)

$iUbound = UBound($aID)
If UBound($aName) > $iUbound Then $iUbound = UBound($aName)

$List1 = GUICtrlCreateListView("ID|Name", 31, 89, 529, 230)

For $i = 0 To $iUbound - 1
$strData = ""
If UBound($aID) > $i Then $strData &= $aID[$i]
If UBound($aName) > $i Then $strData &= "|" & $aName[$i]
_GUICtrlListView_SetColumnWidth($List1, 0, 40)
_GUICtrlListView_SetColumnWidth($List1, 1, 440)
GUICtrlCreateListViewItem($strData, $List1)
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
Next
EndIf

then up top in the listview i have this:

$List1 = GUICtrlCreateListView("ID|Name", 31, 89, 529, 230)

 you can also prepopulate it  but i chose to just have it start blank for now

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