AutoHotkey Community

It is currently May 24th, 2012, 10:14 pm

All times are UTC [ DST ]




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 417 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 28  Next
Author Message
PostPosted: April 10th, 2007, 3:45 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5346
Location: UK
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?

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 10th, 2007, 4:20 pm 
Offline

Joined: May 27th, 2005, 4:14 pm
Posts: 35
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>


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 10th, 2007, 7:01 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5346
Location: UK
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.

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 10th, 2007, 7:16 pm 
Offline

Joined: May 27th, 2005, 4:14 pm
Posts: 35
Thank you, perfect.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: help me
PostPosted: April 12th, 2007, 11:05 pm 
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)


Report this post
Top
  
Reply with quote  
 Post subject: Re: help me
PostPosted: April 12th, 2007, 11:15 pm 
Offline

Joined: May 27th, 2005, 4:14 pm
Posts: 35
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 12th, 2007, 11:16 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5346
Location: UK
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 :)

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: thanks
PostPosted: April 13th, 2007, 5:54 pm 
Offline

Joined: April 13th, 2007, 5:37 pm
Posts: 1
Location: Spain
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 13th, 2007, 6:36 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5346
Location: UK
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.

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 16th, 2007, 12:15 am 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5346
Location: UK
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

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 21st, 2007, 3:28 pm 
Offline

Joined: March 16th, 2005, 10:33 pm
Posts: 968
Location: Frisia
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?

_________________
Image mirror 1mirror 2mirror 3ahk4.me • PM or Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 21st, 2007, 3:55 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5346
Location: UK
Strange that doesn't happen for me.

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 21st, 2007, 4:04 pm 
Offline

Joined: March 16th, 2005, 10:33 pm
Posts: 968
Location: Frisia
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

_________________
Image mirror 1mirror 2mirror 3ahk4.me • PM or Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 21st, 2007, 4:07 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5346
Location: UK
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.

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 21st, 2007, 4:32 pm 
Offline

Joined: March 16th, 2005, 10:33 pm
Posts: 968
Location: Frisia
Did exactly as you suggested, still the issue remains...

_________________
Image mirror 1mirror 2mirror 3ahk4.me • PM or Image


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 417 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 28  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: mc-lemons and 13 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group