| View previous topic :: View next topic |
| Author |
Message |
Titan
Joined: 11 Aug 2004 Posts: 5043 Location: /b/
|
Posted: Tue Apr 10, 2007 3:45 pm Post subject: Re: Operators ">" and "=" |
|
|
| Venia Legendi wrote: | | Why ist Book2 with a price of 2.0 found by [price>2.0] and it's not found by [price=2.0]? | The parser is case sensitive so "2" should not work and "2.0" should. Could you show the XML document you're using so I can test this? _________________ Chat (IRC) PlusNet Scripts IronAHK Contact by email not private message. |
|
| Back to top |
|
 |
Venia Legendi
Joined: 27 May 2005 Posts: 35
|
Posted: Tue Apr 10, 2007 4:20 pm Post subject: |
|
|
Hello, thank you for the prompt answer, the XML-file ist generated by the example I posted.
| Code: |
<?xml version="1.0" encoding="iso-8859-1"?>
<bookstore>
<book>
<title>title1
</title>
<price>1.0
</price>
</book>
<book>
<title>title2
</title>
<price>2.0
</price>
</book>
<book>
<title>title3
</title>
<price>3.0
</price>
</book>
<book>
<title>title4
</title>
<price>4.0
</price>
</book>
<book>
<title>title5
</title>
<price>5.0
</price>
</book>
</bookstore> |
|
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5043 Location: /b/
|
Posted: Tue Apr 10, 2007 7:01 pm Post subject: |
|
|
Sorry I missed that; I fixed this in version 1.02.
Both [price=2] and [price=2.0] will work now since AutoHotkey sees them as the same numbers in expressions. _________________ Chat (IRC) PlusNet Scripts IronAHK Contact by email not private message. |
|
| Back to top |
|
 |
Venia Legendi
Joined: 27 May 2005 Posts: 35
|
Posted: Tue Apr 10, 2007 7:16 pm Post subject: |
|
|
| Thank you, perfect. |
|
| Back to top |
|
 |
eljose Guest
|
Posted: Thu Apr 12, 2007 11:05 pm Post subject: help me |
|
|
This is my first post, so first of all hello everybody.
I'm learning XML now, and a have a problem. Here is my XML code
| Code: | <?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE tv SYSTEM "xmltv.dtd">
<tv generator-info-name="EPG4cplus - mfsav mod">
<channel id="00000001">
<display-name>CANAL+</display-name>
</channel>
<programme start="20070414005000" stop="20070414005500" channel="00000001">
<title>NBA+++++</title>
<category>nosequepassa</category>
</programme>
<programme start="20070414005500" stop="20070414015500" channel="00000001">
<title>Caribe salvaje</title>
<category>documentales naturaleza</category>
</programme>
</tv>
|
I need to filter the start and stop attributes with actual datetime to show what program is on tv at the moment. and i have no luck.
please help me.
thanks
ough! my source code is:
| Code: |
#Include XPath.ahk
a = C:\down\autohotkey\xpath\cplus.xml
book := XmlDoc(a)
latest := XPath(book, "/tv/programme[@stop>=A_Now]/title[1]/text()")
MsgBox, %latest%
XmlDoc("test2.xml", latest) |
|
|
| Back to top |
|
 |
Venia Legendi
Joined: 27 May 2005 Posts: 35
|
Posted: Thu Apr 12, 2007 11:15 pm Post subject: Re: help me |
|
|
| eljose wrote: |
| Code: |
latest := XPath(book, "/tv/programme[@stop>=A_Now]/title[1]/text()")
|
|
| Code: |
latest := XPath(book, "/tv/programme[@stop>=" A_Now "]/title[1]/text()")
; A_Now in String is A_Now as String
|
BTW: test2.xml ist not XML, it just the string you receive |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5043 Location: /b/
|
Posted: Thu Apr 12, 2007 11:16 pm Post subject: |
|
|
All function parameters are expressions so you have to seperate strings from variables like: "/tv/programme[@stop>=" . A_Now . "]/title[1]/text()"
Edit: Venia Legendi beat me to it, thanks  _________________ Chat (IRC) PlusNet Scripts IronAHK Contact by email not private message. |
|
| Back to top |
|
 |
eljose
Joined: 13 Apr 2007 Posts: 1 Location: Spain
|
Posted: Fri Apr 13, 2007 5:54 pm Post subject: thanks |
|
|
thanks for that quick response (and excuse me for my bad written english) to Ttitan and Venia Legendi
I've tried and works, but reading from http://www.w3.org/TR/xpath-functions/#func-current-dateTime
i've found that function and tried to chace A_Now with current-dateTime. Oh!, surprise i am blocked again.
Can you help me.
thanks in advance. _________________ Visca el Barηa |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5043 Location: /b/
|
Posted: Fri Apr 13, 2007 6:36 pm Post subject: |
|
|
Those functions aren't supported since you can do most of those kind of calculations yourself with AutoHotkey. At the moment only text() and remove() work. _________________ Chat (IRC) PlusNet Scripts IronAHK Contact by email not private message. |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5043 Location: /b/
|
Posted: Mon Apr 16, 2007 12:15 am Post subject: |
|
|
New in v1.03:
- Changed function to return nothing if a node is not found
- Fixed root '//' expression to be able to parse child nodes
- Fixed text() function to retrieve only the highest level node content
- Corrected position where new attributes were inserted
Known limitation: '//' will apply to child nodes if used _________________ Chat (IRC) PlusNet Scripts IronAHK Contact by email not private message. |
|
| Back to top |
|
 |
daonlyfreez
Joined: 16 Mar 2005 Posts: 841 Location: Berlin
|
Posted: Sat Jul 21, 2007 3:28 pm Post subject: |
|
|
I encountered a small problem with XPath.
This example code:
| Code: | #Include %A_ScriptDir%\XPath.ahk
settingsFile := XmlDoc(A_ScriptDir . "\settings.xml")
guiTitle := XPath(settingsFile, "/settings/window/@title/text()")
guiPosX := XPath(settingsFile, "/settings/window/@x/text()")
guiPosY := XPath(settingsFile, "/settings/window/@y/text()")
guiPosW := XPath(settingsFile, "/settings/window/@w/text()")
guiPosH := XPath(settingsFile, "/settings/window/@h/text()")
Gui, +Lastfound +Resize
hWnd := WinExist()
Gui, Add, Text, , Just testing...`n`nResize me, reposition me, and close me`n`nIf you reopen me`, the last saved settings will be used`nfor positioning.
Gui, Show, x%guiPosX% y%guiPosY% w%guiPosW% h%guiPosH%, %guiTitle%
Return
GuiClose:
WinGetPos, nowX, nowY, nowW, nowH, ahk_id %hWnd%
nowW := nowW - 8
nowH := nowH - 54
XPath(settingsFile, "/settings/window/@x/text()", nowX)
XPath(settingsFile, "/settings/window/@y/text()", nowY)
XPath(settingsFile, "/settings/window/@w/text()", nowW)
XPath(settingsFile, "/settings/window/@h/text()", nowH)
XmlDoc(A_ScriptDir . "\settings.xml", settingsFile)
ExitApp
Return |
and this corresponding settings.xml file
| Quote: | <?xml version="1.0" encoding="UTF-8"?>
<settings>
<window title="XPath Test" x="10" y="11" w="271" h="91">
</settings>
|
Every time after I wrote the values back to the file, the file has extra empty lines at the top.
| Quote: | <?xml version="1.0" encoding="UTF-8"?>
<settings>
<window title="XPath Test" x="10" y="11" w="271" h="91">
</settings>
|
| Quote: | <?xml version="1.0" encoding="UTF-8"?>
<settings>
<window title="XPath Test" x="10" y="11" w="271" h="91">
</settings>
|
... etcetera. Could this be fixed? _________________
My AHK stuff on ahk.net / on DropBox (mirror) / @home (if online) |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5043 Location: /b/
|
Posted: Sat Jul 21, 2007 3:55 pm Post subject: |
|
|
Strange that doesn't happen for me. _________________ Chat (IRC) PlusNet Scripts IronAHK Contact by email not private message. |
|
| Back to top |
|
 |
daonlyfreez
Joined: 16 Mar 2005 Posts: 841 Location: Berlin
|
Posted: Sat Jul 21, 2007 4:04 pm Post subject: |
|
|
A new line character does get added for me, between all main/parent nodes btw after a save, not only at the top of the document... weird _________________
My AHK stuff on ahk.net / on DropBox (mirror) / @home (if online) |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5043 Location: /b/
|
Posted: Sat Jul 21, 2007 4:07 pm Post subject: |
|
|
Have you got the latest version 1.03? Try downloading xpath.ahk again, but rather than copying the text click 'Save As...' on the link so characters don't get somehow converted. _________________ Chat (IRC) PlusNet Scripts IronAHK Contact by email not private message. |
|
| Back to top |
|
 |
daonlyfreez
Joined: 16 Mar 2005 Posts: 841 Location: Berlin
|
Posted: Sat Jul 21, 2007 4:32 pm Post subject: |
|
|
Did exactly as you suggested, still the issue remains... _________________
My AHK stuff on ahk.net / on DropBox (mirror) / @home (if online) |
|
| Back to top |
|
 |
|