I have a row in the table:
//*[contains(text(), 'Cape Town')]
and the delete graphic:
//*[contains(#id, 'DeleteLinkButton')]
in the table.
How do I click on //*[contains(#id, 'DeleteLinkButton')] of row //*[contains(text(), 'Cape Town')]?
If you want to find a node with XPath in relation to another node then in most cases you don't want to use an absolute path starting with / or even //, instead you would use a relative path like .//*[contains(#id, 'DeleteLinkButton')] as that would find descendants of the context node where the id attribute value contains DeleteLinkButton.
So with Javascript in the browser you would have e.g.
var myRow = ...;
and then you could call
myRow.ownerDocument.evaluate('.//*[contains(#id, 'DeleteLinkButton')]', myRow, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.click();
Related
I would like to filter out by an id. The value of the id is on a property of the parent. Example:
g.V('1234')
.as('parent')
.out()
.has(id, parent.childId). <--- how do I get the parent id?
How would one approach this?
The closest I've been able to get is the following query, but it seems to ignore the has and simply returns all results of out.
g.V('123')
.as('parent')
.values('childId')
.as('childIdValue')
.select('parent')
.out('hasChild')
.has('id', select('childIdValue'))
EDIT
It works as expected when a vertex property other than the Id is used. Example:
g.V('123')
.as('parent')
.values('childId')
.as('childIdValue')
.select('parent')
.out('hasChild')
.has('childProp', select('childIdValue'))
I've tried all variations of id that I can think of. 'id', id, id().
You can compare an ID using a where by approach. For example something like:
where(eq('parent')).by('childProp').by('childId')
For my data model, I have the following:
type defines an item
The project owns an item
Type is connected to anchors (Suppose the anchor is country)
Item is connected to a particular anchor instance (anchor instance
will have corresponding value for anchor, suppose US)
I am trying to read an item along with the type, anchorNames and anchorValues.
Following is the query I have written:
g.V().hasLabel('Type').as('t')
.outE('DEFINES').inV().hasLabel('Item').has('dataId',’test-id').has('version','1').as('i')
.inE('OWNS').outV().hasLabel('Project').select('i')
.project('i','t','anchorNames','anchorValues')
.by(__.valueMap(true))
.by(__.in().hasLabel('Type').valueMap(true))
.by(out().in().hasLabel('Anchor').values('name').fold())
.by(out().as('AnchorInstance').select('AnchorInstance')
.by(values('value','secondaryValue').fold()).fold())
I get i and t but the result for anchorNames and anchorValues is as follows:
{anchorNames=[status, status, country], anchorValues=[[OK], [US], [FAIL]]}
However I am expecting the following:
{anchorNames=[status, status, country], anchorValues=[[OK], [FAIL], [US]]}
I need the ordering between the anchorNames and anchorValues as shown above.
I think the best approach will be to get the name and the corresponding values together.
g.V().hasLabel('Type').as('t')
.out('DEFINES').hasLabel('Item').has('dataId',’test-id').has('version','1').as('i')
.in('OWNS').hasLabel('Project').select('i')
.project('i','t','anchors')
.by(__.valueMap(true))
.by(__.in().hasLabel('Type').valueMap(true))
.by(out().project('anchorNames','anchorValues')
.by(__.in().hasLabel('Anchor').values('name'))
.by(values('value','secondaryValue').fold()).fold())
Below is the XML structure where I want to get the entries for which element co:isbn is not available:-
<tr:trackingRecord xmlns:tr="https://www.mla.org/Schema/Tracking/tr"
xmlns:co="https://www.mla.org/Schema/commonModule/co"
xmlns:r="http://www.rsuitecms.com/rsuite/ns/metadata">
<tr:journal>
<tr:trackingDetails>
<tr:entry>
<co:trackingEntryID>2015323313</co:trackingEntryID>
<co:publicationDate>2015</co:publicationDate>
<co:volume>21</co:volume>
</tr:entry>
<tr:entry>
<co:trackingEntryID>2015323314</co:trackingEntryID>
<co:publicationDate>2015</co:publicationDate>
<co:isbn>
<co:entry>NA</co:entry>
<co:value>1234567890128</co:value>
</co:isbn>
</tr:entry>
<tr:entry>
<co:trackingEntryID>2015323315</co:trackingEntryID>
<co:publicationDate>2015</co:publicationDate>
<co:volume>21</co:volume>
<co:isbn></co:isbn>
</tr:entry>
<tr:entry>
<co:trackingEntryID>2015323316</co:trackingEntryID>
<co:publicationDate>2015</co:publicationDate>
<co:volume>21</co:volume>
</tr:entry>
</tr:trackingDetails>
</tr:journal>
</tr:trackingRecord>
Please suggest the cts:query for the same.
If you can edit xml structure, add one attribute in entry element, like
<tr:entry isbnPresent="yes"> for isbn present,
<tr:entry isbnPresent="no"> for isbn absent
and based on these field fire search with,
cts:element-attribute-value
on it.
OR
without editing schema, try like, ,
for $i in cts:search(//tr:entry,"2015")
return if(fn:exists($i//co:isbn)) then () else $i
I try to remove an element from an array. This operation
UpdateItemSpec updateItemSpec = new UpdateItemSpec()
.withPrimaryKey("id", id)
.withNameMap(new NameMap().with("#P", "myArray"))
.withValueMap(new ValueMap().withInt(":index", index))
.withUpdateExpression("REMOVE #P[:index]");
table.updateItem(updateItemSpec);
results with com.amazonaws.services.dynamodbv2.model.AmazonDynamoDBException: Invalid UpdateExpression: Syntax error; token: ":index", near: "[:index]"
If I remove ValueMap and concat string like this "REMOVE #P["+index+"]" it works fine but this solution looks ugly (like old bad SQL injection stuff). Is there a way to provide an index as a parameter?
REMOVE - Removes one or more attributes from an item
REMOVE - The UpdateExpression is expected to have attribute name only for REMOVE. It should not contain attribute value similar to SET.
There is no alternative other than String concatenation by some means.
I have a quick question about JQuery. I have dynamically generated paragraphs with id's that are incremented. I would like to take information from that page and bring it to my main page. Unfortunately I am unable to read the dynamically generated paragraph IDs to get the values. I am trying this:
var Name = ((data).find("#Name" + id).text());
The ASP.NET code goes like this:
Dim intI As Integer = 0
For Each Item As cItem in alProducts1
Dim pName As New System.Web.UI.HtmlControls.HtmlGenericControl("p")
pName.id = "Name" & intI.toString() pName.InnerText = Item.Name controls.Add(pName) intI += 1
Next
Those name values are the values I want...Name1, name2, name3 and I want to get them individually to put in their own textbox... I'm taking the values from the ASP.NET webpage and putting them into an AJAX page.
Your question is not clear about your exact requirement but you can get the IDs of elements with attr method of jQuery, here is an example:
alert($('selector').attr('id'));
You want to select all the elements with the incrementing ids, right?
// this will select all the elements
// which id starts with 'Name'
(data).find("[id^=Name]")
Thanks for the help everyone. I found the solution today however:
var Name = ($(data).find('#Name' + id.toString()).text());
I forgot the .toString() part and that seems to have made the difference.