This is my first time posting to the forums.
<edit>
whoops. totally forgot about the other two posts i made. NVM about this part. lol.
</edit>
Not sure if this question goes here or in a new ask-for-help thread.
I'm new to xpath, and xml in general.
Using xpath 3.13c. Haven't fiddled with xpath4.
I'm trying to write a script to look for the content in /sets/set/object/title/text()
where /sets/set/object/bottom/edge/amount/text() is a specific value.
I do not want multiple title values returned, just the one that corresponds to the bottom/edge/amount/text().
Code:
<?xml version="1.0" encoding="utf-8"?>
<sets>
<set>
<title>water_shallow</title>
<object width="1" height="1">
<title>HJ</title>
<tiles>
<row pos="1">HJ</row>
</tiles>
<top>
<edge pos="1">
<objectmatch></objectmatch>
<amount>full</amount>
<theme>water</theme>
<type position="1">water</type>
</edge>
</top>
<bottom>
<edge pos="1">
<objectmatch></objectmatch>
<amount>full</amount>
<theme>water</theme>
<type position="1">shallow</type>
</edge>
</bottom>
<left>
<edge pos="1">
<objectmatch></objectmatch>
<amount>full</amount>
<theme>water</theme>
<type position="1">shallow</type>
</edge>
</left>
<right>
<edge pos="1">
<objectmatch></objectmatch>
<amount>full</amount>
<theme>water</theme>
<type position="1">water</type>
</edge>
</right>
</object>
<object width="1" height="1">
<title>GZ</title>
<tiles>
<row pos="1">GZ</row>
</tiles>
<top>
<edge pos="1">
<objectmatch></objectmatch>
<amount>full</amount>
<theme>water</theme>
<type position="1">water</type>
</edge>
</top>
<bottom>
<edge pos="1">
<objectmatch></objectmatch>
<amount>full</amount>
<theme>water</theme>
<type position="1">shallow</type>
</edge>
</bottom>
<left>
<edge pos="1">
<objectmatch></objectmatch>
<amount>half</amount>
<theme>water</theme>
<type position="1">water</type>
<type position="2">shallow</type>
</edge>
</left>
<right>
<edge pos="1">
<objectmatch></objectmatch>
<amount>full</amount>
<theme>water</theme>
<type position="1">water</type>
</edge>
</right>
</object>
<object width="1" height="1">
<title>Go</title>
<tiles>
<row pos="1">Go</row>
</tiles>
<top>
<edge pos="1">
<objectmatch></objectmatch>
<amount>full</amount>
<theme>water</theme>
<type position="1">water</type>
</edge>
</top>
<bottom>
<edge pos="1">
<objectmatch></objectmatch>
<amount>half</amount>
<theme>water</theme>
<type position="1">shallow</type>
<type position="2">water</type>
</edge>
</bottom>
<left>
<edge pos="1">
<objectmatch></objectmatch>
<amount>full</amount>
<theme>water</theme>
<type position="1">shallow</type>
</edge>
</left>
<right>
<edge pos="1">
<objectmatch></objectmatch>
<amount>full</amount>
<theme>water</theme>
<type position="1">water</type>
</edge>
</right>
</object>
</set>
</sets>
Code:
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
#include xpath.ahk
inputbox, userin, object name, Input the object title
xpath_load(myxml, "tileborderdefs.xml")
title := xpath(myxml, "/sets/set[title = water_shallow]/object[title =" . userin . "]/title/text()")
amount := xpath(myxml, "/sets/set[title = water_shallow]/object[title =" . userin . "]/top/edge[1]/amount/text()")
theme := xpath(myxml, "/sets/set[title = water_shallow]/object[title =" . userin . "]/top/edge[1]/theme/text()")
type := xpath(myxml, "/sets/set[title = water_shallow]/object[title =" . userin . "]/top/edge[1]/type/text()")
msgbox Title: %title% `nTop edge:`n Amount: %amount%`n Theme: %theme%`n Type: %type%
;here is where I'm having trouble
match := xpath(myxml, "/sets/set[title = water_shallow]/object[bottom/edge/amount =" . amount . "]/title/text()")
msgbox %match%
I'm really not sure what syntax i should be using here, or if there is simply no direct way to do what i want to do.
I tried searching through the forums for a solution, but didn't find anything. If this answer has already been posted and I missed it, then I apologize.