AutoHotkey Community

It is currently May 26th, 2012, 2:29 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 ... 22, 23, 24, 25, 26, 27, 28  Next
Author Message
 Post subject:
PostPosted: January 21st, 2009, 9:25 pm 
Offline

Joined: May 9th, 2006, 6:22 pm
Posts: 75
bmcclure wrote:
Are you using v3 of xpath, or the development (v4) version?
I'm using Version 3.13c, I looked at v4 but it seems Load and Save is missing so I'm not sure how to use it, if it is working.
Edit: I could just use StringReplace to change them back before saving. :wink:

jonib


Report this post
Top
 Profile  
Reply with quote  
 Post subject: about DTD
PostPosted: February 1st, 2009, 9:35 pm 
Offline

Joined: February 1st, 2009, 9:27 pm
Posts: 1
I am facing problem writing DTD file.

I want to write DTD syntax of the XML tree like this example: "Marks" is a node and it has two children "Pass" and "Fail". If value of the marks is less than 60 then "Fail" and if marks is greater that 60 then "Pass".

How can write this above scenarion in DTD syntax.

Could anyone please help me?

I will be grateful to u.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 17th, 2009, 1:31 am 
Offline

Joined: November 24th, 2007, 9:07 pm
Posts: 774
I have an issue specifying an element that contains brackets in xpath. Should I be escaping something?

My XML has a line like this:

<mod id="EnclaveRadio10[S].esp" />

When trying to get it with:
xpath(XML, "mod[@id="EnclaveRadio10[S].esp"]/@id/text()")
Nothing is returned

However if I get the file by index:
xpath(XML, "mod[1]/@id/text()")
The id is returned properly

My XML file is larger and more complex than this, but none-the-less it works for files without brackets (don't know about other special characters), so I thought I would trim it down for this example.

Update: This continues to be an issue; I can't find a way around it other than converting the brackets to something else, and then converting them back when reading the XML, but since the XMLs can also be made manually by users, that's not really an option.

_________________
Ben

My Trac projects
My Wiki
[Broken] - My music


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 22nd, 2009, 10:30 pm 
Offline

Joined: November 7th, 2006, 9:47 pm
Posts: 1934
Location: Germany
I am trieng to upgrade from version 1 of xpath to version 3 and have massive problems. I try to update all old xpath occurrence with new calls.

In old days with xpath 1, I did often this:
Code:
ConfigDoc := XmlDoc(ConfigFile)
NodeCommands := XPath(ConfigDoc, "/hiscoreRecConfig/commands")
MsgBox % XPath(NodeCommands, "/hiscoreRecConfig/commands/command[@name=mame]/command/text()")


to enable faster calls, because in this case xpath() does not need to search full document, just the little section which is needed. (this works.)

If I now try this with xpath 3, ill get empty string:
Code:
xpath_load(ConfigDoc, ConfigFile)
NodeCommands := XPath(ConfigDoc, "/hiscoreRecConfig/commands")
MsgBox % XPath(NodeCommands , "/hiscoreRecConfig/commands/command[@name=mame]/command/text()")
(changed a copy paste error)

it does not work anymore. I want use subsets / parts of a xml file. Why does it not work? On bigger xml files, could this not be a speed up at Loops with high frequently calls of same subset?

Here is the configuration file:
Code:
<?xml version="1.0" encoding="iso-8859-1"?>

<hiscoreRecConfig>
    <options>
        <option name="autoSave">0</option>
        <option name="exportAutoRun">1</option>
        <option name="scoreDelimChar">,</option>
        <option name="searchMatchType">InStr</option>
        <option name="speedCompareThreshold">5</option>   
        <option name="listTitleCount">12</option> 
        <option name="defaultLabelName1">stage</option>
        <option name="defaultLabelName2">vehicle</option>
        <option name="defaultLabelName3">character</option>
    </options>
    <users>
        <user name="player">Tuncay</user>
        <user name="rival">Akira</user>
    </users>
    <path>
        <file name="var">var.ini</file>
        <file name="highscores">hiscore.xml</file>
        <folder name="backup">backup</folder>
        <folder name="programs">bin</folder>
        <folder name="cache">cache</folder>
        <folder name="export">export</folder>
        <folder name="highscores">inp</folder>
        <folder name="snap">snap</folder>
        <folder name="ico">icons</folder>
    </path>
    <commands>
        <command name="mame">E:\Tuncay\Emulatoren\Mame\Mamepp.exe</command>
        <command name="compress">bin\7z.exe a -t7z -mx1</command>
        <command name="uncompress">bin\7z.exe e</command>
        <command name="scripteditor">C:\Programme\Vim\vim72\gvim.exe</command>
        <command name="editor">C:\Programme\Vim\vim72\gvim.exe</command>
    </commands>
</hiscoreRecConfig>


Last edited by Tuncay on February 22nd, 2009, 11:10 pm, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 22nd, 2009, 11:00 pm 
Offline

Joined: November 24th, 2007, 9:07 pm
Posts: 774
If I'm not mistaken, your variable NodeCommands only contains the content of the "commands" node. So when you call xpath(NodeCommands, ...) your top-level paths will be your <command> nodes. You shouldn't call the nodes above that, since they aren't in the variable.

Additionally, I don't think you should be using the XmlDoc command with version 3, unless it's a custom command you made. Use xpath_load or xpath_save to load and save a document.

_________________
Ben

My Trac projects
My Wiki
[Broken] - My music


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 22nd, 2009, 11:15 pm 
Offline

Joined: November 7th, 2006, 9:47 pm
Posts: 1934
Location: Germany
sorry, I am using xpath_load() with version 3. I have corrected that in example, it was just another typo...

It worked for years you could say, I am not new to xml and xpath.

After that example of me above NodeCommands contains

Code:
    <commands>
        <command name="mame">E:\Tuncay\Emulatoren\Mame\Mamepp.exe</command>
        <command name="compress">bin\7z.exe a -t7z -mx1</command>
        <command name="uncompress">bin\7z.exe e</command>
        <command name="scripteditor">C:\Programme\Vim\vim72\gvim.exe</command>
        <command name="editor">C:\Programme\Vim\vim72\gvim.exe</command>
    </commands>


Either of following arent working, with or without leading slash:
Code:
MsgBox % XPath(NodeCommands, "/command[1]")
MsgBox % XPath(NodeCommands, "commands/command[1]")


... additional note... the xpath expression works fine with given full pathes directly operating on full document.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 22nd, 2009, 11:21 pm 
Offline

Joined: November 24th, 2007, 9:07 pm
Posts: 774
Hmm, the contents of the variable seem fine, but I'm used to using xpath() with variables returned from xpath_load(), not variables containing raw XML data.

I'm not sure if that's the issue, but if so, I think you might need to pass the string through xpath_load and use the returned value in xpath() instead of the raw xml.

Or you could get the subnodes directly from the xml document, but that would be slower with a large number of them.

_________________
Ben

My Trac projects
My Wiki
[Broken] - My music


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 22nd, 2009, 11:31 pm 
Offline

Joined: November 7th, 2006, 9:47 pm
Posts: 1934
Location: Germany
I tried xpath_load() on subsets also, but it wont work. In documentation (which is outdated) stands it would accept strings directly.

Seems this to be a bug?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 22nd, 2009, 11:38 pm 
Offline

Joined: November 7th, 2006, 9:47 pm
Posts: 1934
Location: Germany
Hey, I think, I found the problem. I did fileappended the subset in a file and opened it with Vim. There is a note, that the end of file marker is missing. xpath seems to be removing it. (problem continues)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 23rd, 2009, 7:55 pm 
Offline

Joined: November 7th, 2006, 9:47 pm
Posts: 1934
Location: Germany
Please help, what can I do?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 23rd, 2009, 9:38 pm 
Offline

Joined: November 24th, 2007, 9:07 pm
Posts: 774
I've been trying to get some help with the bug I found a few posts back, too; it seems Titan is taking a (well-deserved) break :)

Hopefully he or someone else is able to assist with this soon, however!

_________________
Ben

My Trac projects
My Wiki
[Broken] - My music


Report this post
Top
 Profile  
Reply with quote  
PostPosted: February 27th, 2009, 2:59 am 
Offline

Joined: February 27th, 2009, 2:50 am
Posts: 2
Location: Barcelona
My english is very limitated.

Error: Call to nonexistent function.

I try to learn the Xpath tips, but all the time the same error.

i place de xpath.ahk in the same folder of the script that i would run.

what is the procedure to install xpath library?

i'm sure it's a simple thing.

i use the samples in the post to train, and anything run.

Thanks for all.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 27th, 2009, 3:35 am 
Offline

Joined: November 24th, 2007, 9:07 pm
Posts: 774
One of three ways:

    Put xpath.ahk in your My Documents\AutoHotKey\lib\ folder
    Put xpath.ahk in your AutoHotKey\lib\ folder
    Put the following line in your script:

    Code:
    #Include xpath.ahk

_________________
Ben

My Trac projects
My Wiki
[Broken] - My music


Report this post
Top
 Profile  
Reply with quote  
PostPosted: March 1st, 2009, 6:58 pm 
Offline

Joined: July 22nd, 2008, 2:33 pm
Posts: 7
How do I use multiple conditions at the same level in Xpath?

This seems to be a valid search condition given this XML testing tool, but Xpath doesn't return the email node as I'd expect. It finds no matches:

theXML
Code:
<addressBook>
     <address>
          <firstName>John</firstName>
          <surname>Smith</surname>
          <email>smithj@world.org</email>
          <tel type = "work">234-123-222</tel>
     </address>
     <address>
          <firstName>Alice</firstName>
          <surname>Brown</surname>
          <email>Alice.Brown@europe.com</email>
          <tel type = "home">22-33-444</tel>
          <tel type = "work">11-43-222</tel>
     </address>
     <address>
          <firstName>George</firstName>
          <surname>White</surname>
          <email>gw@rock.com</email>
     </address>
</addressBook>

Code:
xpath_load( theXML )
MsgBox, % xpath_save(theXML) ;

msgbox, % xpath(theXML, "/*/address[firstName=John][surname=Smith]/email/text()")



using the exact same XML and Xpath (with double quotes of course), it works with this testing tool:

http://www.zvon.org:9001/saxon/cgi-bin/XLab/XML/addressbook.html?stylesheetFile=XSLT/xpath.xslt&lang=eng


What is the syntax for using multiple conditions on multiple nodes at the same level?

FYI - I'm using Xpath Version 3.13c


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 16th, 2009, 11:33 pm 
Offline

Joined: July 12th, 2005, 1:21 pm
Posts: 633
Hey guys! Long time no see :)

I've a little problem with XML now.
Isn't it possible to create new nodes with values?

I've a saving-routine this way:
Code:
xpath(XMLDoc, "/files/file[@name='" Programmname "']/Sprache/text()", Sprachen)
xpath(XMLDoc, "/files/file[@name='" Programmname "']/OS/text()", Operatingsystem)
xpath(XMLDoc, "/files/file[@name='" Programmname "']/Bewertung/text()", Bewertung)
xpath_save(XMLDoc, XMLFile)

But it does only change existing entries and does not create new nodes?

Background:
I'm trying to edit and fill a XML-File with data. The structure is:
Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<files>
  <file name="Test1" hide="1">
    <Sprache>DEat</Sprache>
    <OS>Win</OS>
  </file>
  <file name="Test2" hide="0">
    <Bewertung>3</Bewertung>
    <Sprache>DEat,ENus,ENuk</Sprache>
  </file>
</files>
I've no problems with creating attributes (like "hide" above), and I've no problem changing "OS" for "Test1", but I'm not able to add "OS" for "Test2" :?:
This would be a real problem, because most of the items don't have all nodes (like "OS" or "Bewertung") :(

I hope I haven't missed some limitation and I'm only too stupid for this :)

If it isn't that easy I'll create a working example.. (my actual test-code has more than 500 lines of code ^^)

Thanks,
Thalon

Edit:
And a little additional question:
How is it possible to save several equal named elements like
Code:
   <file>
    <Sprache>DEat</Sprache>
    <Sprache>ENus</Sprache>
    <Sprache>ENuk</Sprache>
    <Sprache>fr</Sprache>
    <Sprache>de</Sprache>
   </file>
?

_________________
AHK-Icon-Changer
AHK-IRC
deutsches Forum


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 ... 22, 23, 24, 25, 26, 27, 28  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google Feedfetcher and 15 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