XPath Query using NOT, not working - xpath

I'm trying to figure out how to selected all of the Suppliers who do not have TV as a product. I'd also like an explanation on the differences of your answer and what I have.
I have the following query written:
SELECT XMLColumn.query('/SuppliersList/Supplier/Product[not(#name="TV")]/..')
FROM Tb_XPathQueryTable
This is my table, plus a bunch of other Suppliers.
<SuppliersList>
<Supplier name="Joe">
<City>Paris</City>
<Product name="Airplane"/>
<Product name="Milk"/>
<Product name="TV"/>
<Product name="Orange"/>
</Supplier>

On your xpath you are selecting first the Product and then going to its parent, so it will match the specified example (because the TV Product has siblings that match the same parent).
This xpath should work:
/SuppliersList/Supplier[not(Product[#name="TV"])]
As you can see, we are selecting Supplier which doesn't contain a Product child with name="TV"

Related

How to select an item in UiPath that starts with a string

I'm using UiPath to select an item from a combobox in a windows rich client application. The items are formatted in the list as "Code - Description". I'd like to select the item by code only, rather than needing to know the description also.
As a UIPath newbie, thoughts on the best way to achieve this?
Just use a wildcard in selector. Given that Code is unique i.e 0001 and attribute name equals to id:
<id = 0001* />
Additionally, this link should be helpfull:
https://studio.uipath.com/v2017.1/docs/selectors-with-wildcards

Can some one help me as how to write the correct Xpath to get the different condition prices

Can some one help me as how to write the correct Xpath to get the different condition prices from this site?
I want the prices $75.00 and $45.00 but when I use //*[#id="price"], I get :
Please answer all questions at left to get your price" while in the Sheets.

What's wrong with this XPath expression

I want to display students in a repeat table called 'table1'. when the user click on one of them the details of the student enrollments will be displayed.
I ttried this, taking the index from the table then I compared the student id in the enrollment instance with the id in the students instance.
<xf:repeat nodeset="/instance('enrollInstance')/enrollment[Student_idStudent=student[index('table1')]/idStudent]">
nothing is displayed when I write this
<xf:output ref="Course_idCourse"/>
where Course_idCourse is an element in the enrollment
the xml file looks like this
</enrollment>
<Course_idCourse>1</Course_idCourse>
<Student_idStudent>2</Student_idStudent>
<year>2014</year>
<Semester>1</Semester>
<mark>50</mark>
<idEnrollment>1</idEnrollment>
</enrollment>
there is a student xml file that looks like this
<Student>
<idStudent />
</Student>
I appreciate your help.
The issue (based on that example XML) is that you are targeting a non-existant node. Looking at just this bit:
/enrollment[Student_idStudent=student[index('table1')]/idStudent]
You are looking for an enrollment node, that has a Student_idStudent child element, with a subsequent child idStudent element.
Yet in the example XML you have an enrollment element, with a Student_idStudent child element that contains text, but no child elements within it. So the Xpath will never match anything.

xpath - get count of rows based on some text

I'm writing xpaths to select all the links under each category on left sidebar from following page:
http://www.indexmundi.com/commodities/'>http://www.indexmundi.com/commodities/
I want to select the link under each category one by one. I've written the following xpath and it is selecting the link under first category(Commodity Price Indices) somehow. But I was wondering how I will select the links under other categories. I want to add a check on h3 tha if it's text is Energy, count and select all the rows before that, then if h3 text is Beverages, count and select all rows between Energy and Beverages
.//*[#id='dlCommodities']/tbody/tr[position()< count(following-sibling::tr/td/h3)-1]/td/a
Here is another xpath:
.//*[#id='dlCommodities']/tbody/tr[preceding-sibling::tr/td/h3[. = 'Energy'] and following-sibling::tr/td/h3[. = 'Beverages']]/td/a
It is fulfilling the second requirement i.e. select rows between specific headings but it is missing one node.
Please help me fix these xpaths or suggest a better one.
Thanks
I understand your actual problem as: Find all links that belong to a given category. For doing so, find the category, and then retrieve all elements before the next category.
You might remove the newlines if you prefer, I added them for readability.
//tr[td/h3="Energy"]/(self::tr, following-sibling::tr[
. << //tr[td/h3="Energy"]/following-sibling::tr[td/h3][1]
])
If you do not have an XPath 2.0 compatible processor, you cannot use the << operator which test for node order (the current node must precede the next category). An XPath 1.0 solution is even slightly shorter, but in my opinion worse in readability:
//tr[td/h3="Energy"] | //tr[td/h3="Energy"]/following-sibling::tr[
./preceding-sibling::tr[td/h3][1][td/h3="Energy"] and not(td/h3)
]
Both queries will select all nodes of a category; to count them wrap them into count(...).

importing csv (magento)

I have a certain attribute dealer_country in my website, which is a dropdown attribute containing a list of all countries. However, in my csv file, the dealer_country attribute will be containing country codes(in 2-letter format). Would it be possible to import with this condition?
Yes. There is an easy way and a hard way.
If programming is your bag then you can get your attribute hooked up to the Magento country codes and have it return country names on the front end.
It would take a while to write such an ideal solution. However you can use a 3rd party import tool like 'Magmi' to get your products in without having to define your attribute values first.
Once in you can edit your attribute entries for country and, in the second column put the country names to be shown on the front end. e.g. for 'GB' in column one you have 'United Kingdom of Great Britain and Northern Ireland' in column two. Or for 'LY' you can add 'The Great Socialist People's Libyan Arab Jamahiriya' for column two... Oops!
http://sourceforge.net/apps/mediawiki/magmi/index.php?title=Main_Page

Resources