I want to find elements containing name and age.
But Name can contain whitespace like "Jo hn", So I want to remove whitespace between strings.
So I made code below, but SyntaxError. How can I do this?
driver.find_elements_by_xpath('//*[#id="Nlist"]/section/ul/li/a/span[contains(text().replace(" ", ""),"' + NAME + '") and contains(.,"' + AGE + '")]')
text().replace(" ", "") is Syntax Error. Is there any method?
I need to do this when find elements because speed.
Here is the sample html used to trim the space(s) with in name and used contains to match the partial text.
<!DOCTYPE html>
<html>
<body>
<span>s upputuri-100</span>
<span>s upp uturi-100</span>
</body>
</html>
You can use translate method to replace the white space(s) with the desired char/empty. Below the xpath to get the span that contains supputuri and 100.
//span[contains(translate(.,' ' ,''),'supputuri')][contains(.,'100')]
Related
I have a code in my application to print some data in word.
Somewhere in the code I do this:
gerarSumarioSeger = gerarSumarioSeger + |<p>| + docP.ds_assunto(0) + |</p>|
I assemble the HTML getting the data from the field in the document. Ok, not hard at all.
But, if I try to print two of the documents that have in this field the data like in the image
the word is generated with the error in image
If I remove one of the "çã" in one of the fields the error doesn't occur.
If I put a hidden field with a special character like below the error doesn't occur:
<p style="visibility:hidden;">ã</p>
If I select another document with the content in the field like bellow the error doesn't occur:
Convênio de Cooperação Geral - Sebrae e Ministério do Desenvolvimento
Social e Agrário - MDSA
I think you have to add the character set to your html, something like:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
With help from Branded, i have tag working. At this point, we don't need tags to link, so i have tags being displayed like this (in an ascx transformation):
<p class='date'><%# IfEmpty(Eval("DocumentTags"),"",Eval("DocumentTags").ToString() + " | ") %><%# FormatDateTime(Eval("Date"),"MMM d, yyyy") %></p>
This works, but i get the tags wrapped in double quotes. I'm traying TrimEnd, or LastIndexOf, but just getting errors.
Use the method Replace() on the double quotes. Something like Eval<string>("DocumentTags").Replace("\"", "") should work.
I want to write a xquery statement that returns a number plus a string called " books". Like this:
<table>
<tr><td>300 books</td></tr>
<tr><td>145 books</td></tr>
</table>
I've started writing the code, but it doesn't work...
<tr><td>{$num + 'books'}</td>
Any help with this?
Move the literal string " books" outside of the expression:
<tr><td>{$num} books</td></tr>
Or you could create a sequence of items by enclosing it inside of parenthesis and separating with a comma:
<tr><td>{($num, 'books')}</td></tr>
Or you could concatenate the items (notice the leading space):
<tr><td>{concat($num, ' books')}</td></tr>
A random string.
A random string 2.
<!-- Hosting24 Analytics Code -->
<script type="text/javascript" src="http://stats.hosting24.com/count.php"></script>
<!-- End Of Analytics Code -->
What I want to do?
Strip off the hosting24 analytics code
Divide the string into different strings based on the line breaks, so that the A random string. and A random string 2. are two different strings.
How do I achieve this in ActionScript3?
var lines:Array = str.split("\n");
You can ignore the extra lines, or you can slice:
var twoLines:Array = lines.slice(0,2);
I Have some text file. theses texts contain a string like this(a part of text):
<abbr class="word p1"">dd</abbr>
<img src"D:\Images\1.png">
<abbr class="word p1">dd</abbr>
<img src"D:\ticket\t\1.png">
In each text file,(D:\Images\1.png) png name is different but it is always numbers(from 1 to 114)for example(1,2,3,10,...)
I want to replace this text D:\Images\[number].png with a specific text for expample:
string newtext=Replace("D:\Images\[number].png","Something");
How can i do this?
thanks.
Use a regular expression:
string newtext = Regex.Replace(text, #"(D:\\Images\\)\d+(.png)","$1Something$2");
It will replace the full match, including D:\Images\ and .png, so $1 and $2 puts back what's caught by the parentheses, so that Somthing only replaces the digits.
Use regular expressions that are represented mostly be the Regex class. See these links:
http://www.codeproject.com/Articles/93804/Using-Regular-Expressions-in-C-NET
http://msdn.microsoft.com/en-us/library/ms228595%28v=vs.80%29.aspx