Jump to content
Sign in to follow this  
pcguru000

XML -> TXT

Recommended Posts

pcguru000

Alright so simply put (since its 6:30 in the morning and i haven't gone to sleep yet) I am looking to make a simple program that download a .xml file from my moms site ... it controls a list of gigs organized by month, each with there own description etc etc... acts very much like an rss feed...

I was considering making a program in autoit to replace the one i made years ago for her in game maker....

essentially the old one will download the file - save it locally and then quickly open in in notepad... she edits it (which is scary b/c she looks directly at XML and shes the most computer illiterate person I know...) saves it... and then clicks a button which tells the program to then upload it back to the server and replace the old file.

What can AutoIt do for me to make this proccess easier for her so that I dont have to worry about her destroying the xml file etc etc...

PS

My thought was a program that could load each entry of the xml file into input boxs...

By the way - the xml file looks like this:

<channel>

<item>

<title>BLAH</title>

<description>DSFLKS:LFD:SLFSLFLSFodfijsofijfls;fi</description

</item>

<item>

<title>BLAH</title>

<description>DSFLKS:LFD:SLFSLFLSFodfijsofijfls;fi</description

</item>

<item>

<title>BLAH</title>

<description>DSFLKS:LFD:SLFSLFLSFodfijsofijfls;fi</description

</item>

<item>

<title>BLAH</title>

<description>DSFLKS:LFD:SLFSLFLSFodfijsofijfls;fi</description

</item>

</channel>

TY in advance.

Share this post


Link to post
Share on other sites
Zedna

You can do this in AutoIt.

Look at:

- InetGet()

- XML DOM wrapper (COM) UDF http://www.autoitscript.com/forum/index.ph...9848&hl=xml

- FTP UDF (FTPUpload) http://www.autoitscript.com/forum/index.php?showtopic=12473

also look at XML in treeview, Quick and dirty XML to treeview http://www.autoitscript.com/forum/index.ph...0046&hl=xml

And in this simple XML structure you can use ListView control for display/edit XML data.

Edited by Zedna

Share this post


Link to post
Share on other sites
TonyP

Just curious if you got this to work?

Share this post


Link to post
Share on other sites
weaponx

I started working on this when it was first posted but it was a pain in the ass. AutoIt is NOT good for creating dynamic forms.

This will get all of the data into a listview. No editing takes place so far.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ListviewConstants.au3>
#include <GuiListView.au3>
#include "../_XMLDomWrapper.au3"

Dim $GUI_Width = 600, $GUI_Height = 400
Dim $sFile = "Untitled-4.xml"

$hGUI = GUICreate("My GUI",$GUI_Width,$GUI_Height)  ; will create a dialog box that when displayed is centered
GUISetState(@SW_SHOW)       ; will display an empty dialog box

$Margin = 4
$ListView = GUICtrlCreateListView ( "Title|Description", $Margin, $Margin ,$GUI_Width-($Margin*2),$GUI_Height-50,BitOR($LVS_EDITLABELS, $LVS_REPORT))
;$hListView = _GUICtrlListView_Create($hGUI,"",$Margin, $Margin ,$GUI_Width-($Margin*2),$GUI_Height-50,BitOR($LVS_EDITLABELS, $LVS_REPORT))
;_GUICtrlListView_InsertColumn($hListView, 0, "Title", 100)
;_GUICtrlListView_InsertColumn($hListView, 1, "Description", 100)

;Open XML File if it exist, else error
If FileExists($sFile) Then
    $ret = _XMLFileOpen($sFile)
    If $ret = 0 Then Exit
    
    ;Count item nodes below root
    $count = _XMLGetNodeCount("//item")
    
    For $X = 1 to $count
        $Title = _GetFirstValue("//item[" & $X & "]/title")
        $Description = _GetFirstValue("//item[" & $X & "]/description")

        GUICtrlCreateListViewItem ($Title & "|" & $Description, $ListView)
        ;_GUICtrlListView_AddItem ($hListView, $Title & "|" & $Description)
        ;ConsoleWrite("Title: " & $Title & @CRLF)
        
        ;_GUICtrlListView_AddItem($hListView, $Title, 0)
        ;_GUICtrlListView_AddSubItem($hListView, $X, $Description, 1, 1)        
    Next
Else
    MsgBox(4096, "Error", _XMLError())
EndIf

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

;Get the first real value returned from the _XMLGetValue() return array.
Func _GetFirstValue($node)
    $ret_val = _XMLGetValue($node)
    If IsArray($ret_val) Then
        Return ($ret_val[1])
    Else
        Return SetError(1,3,0)
    EndIf
EndFunc
Edited by weaponx

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  

×