TD element in table , is a block level element or inline level ?
in tr tag , we can have multi TD element . now i have a question : td element is a inline element ? or not ?
From a style perspective, td is (by default) a table-cell element. These are more like inline-block than they are like block, but they're different from both. They're their own thing.
Related
I am trying to get the xpath equivalent of this css_selector of this website.
To get 6 elements I add: div:nth-child(1). For xpath it would be //div[1] yet this makes no difference. I am wanting all the 6 numbers under the left result tab
Css:
div:nth-child(1) > proposition-return > div > animate-odds-change > div > div
Returns 6 elements
xpath (quite similar):
//div[#class='propositions-wrapper'][1]//div[contains(#class, 'proposition-return')]//animate-odds-change//div//div
Returns 18
I desire 6.
<div ng-repeat="odd in odds" class="animate-odd ng-binding ng-scope" ng-class="{
'no-animation': oddsShouldChangeWithoutAnimation
}" style="">2.05</div>
Those are totally different selectors:
CSS: div:nth-child(1) > proposition-return > div > animate-odds-change > div > div
Find every div that is the first child of its parent, then get its direct proposition-return child (I assume you wanted to use it like .proposition-return, then its direct div and so on..
XPATH: //div[#class='propositions-wrapper'][1]//div[contains(#class, 'proposition-return')]//animate-odds-change//div//div
Find all div elements with proposition-wrapper as class, then only get the first. After, find all div with proposition-return class that are descendant of the previous element and so on..
[1] is very different to nth-child(1) to begin with, and also // is not the same as >, but / is.
For getting the specific elements that you want, I would use this xpath:
//div[contains(#class, "template-item")]//div[#data-test-match-propositions]/div[1]//div[contains(#class, "animate-odd")]
that site is not available worldwide, but looking at the img you provided helps. as eLRuLL points out, your xpath is not equivalent to the css.
try getting rid of some of the double slashes
//div[#class='propositions-wrapper']//div[contains(#class, 'proposition-return')]/animate-odds-change/div/div[contains(#class, 'animate-odd')]
I have an svg element with multiple g tags inside it. Typically, when I select a tag by name, I get a list of all tags on the page. For example, this returns a list of Selenium WebElement instances:
browser.find_elements_by_xpath('//a')
But when I try to select all the g tags inside my svg element, I only get the first element returned. For example:
browser.find_element_by_xpath('//*[name()="svg"]/*[name()="g"]')
And here my markup:
<svg xmlns="http://www.w3.org/2000/svg">
<g>...</g>
<g>...</g>
<g>...</g>
...
</svg>
How can I select all the g tags?
That because you used find_element_by_xpath which returns the first element. To return all the elements then use find_elements_by_xpath:
browser.find_elements_by_xpath('//*[name()="svg"]/*[name()="g"]')
But I would use a CSS selector which is shorter:
browser.find_elements_by_css_selector('svg > g')
Here is how I would do it:
With the following XML:
...
<svg>
<g>1</g>
<g>2</g>
<g>3</g>
</svg>
...
Then use this XPath expression:
//svg/g
This will return 3 nodes, as shown on this site: http://www.freeformatter.com/xpath-tester.html
NOTE1: If you introduce the namespace on the svg tag, you will see this error from the above site: The default (no prefix) Namespace URI for XPath queries is always '' and it cannot be redefined to 'http://www.w3.org/2000/svg'.
NOTE2: Another similar question here: XPath Error - The default (no prefix) Namespace URI for XPath queries is always ''
I'd like to extract a list of divs (including their children, for further processing) which contain one or more <p class="c8"> child tags, using BeautifulSoup 4, but I haven't had any luck using the CSS selector syntax. Can I use find_all and a boolean function, or is there a better way?
There are different ways to approach the problem. One, is to locate all p elements having class="c8" and find the parent div element:
for p in soup.find_all("p", class_="c8"):
div = p.find_parent("div")
You can also write a function to find all div elements checking that there is a desired child:
def filter_div(elm):
return elm.name == "div" and elm.find("p", class_="c8")
for div in soup.find_all(filter_div):
# do smth with div
I am new to div stylesheet and i only discovered how to use :
margin-top/left/right/bottom.
What is the position used for ?
What is left/right/top/bottom attrib used for?
What is display used for?
Is there any other attrib which i need to take note of/usage for positioning my div ?
Regards
http://www.w3schools.com/css/pr_class_position.asp
http://www.w3schools.com/css/pr_pos_left.asp
http://www.w3schools.com/css/pr_class_display.asp
http://www.w3schools.com/css/css_positioning.asp
margin is in relation to the closest container while left/right... is in relation to the entire page.
Display determines if the object is visible/hidden or how the element behaves. Like display: inline means the elements will display on the same horizontal plane if possible.
Im using HtmlAgilityPack/HAP so that I can use Xpath with HTML documents.
I need help selecting the preceding-sibling of div class="address" in this url:
www.yellowpages.ca/search/si-geo/1/sh/Ottawa,+ON
The sibling that I want is h3 class="listingTitleLine"
Here is a screenshot:
http://i55.tinypic.com/25gc4qo.png
Can I get some help please.
-Dd,
To select the preceding-sibling H3 element with the class attribute value of "listingTitleLine":
preceding-sibling::h3[#class='listingTitleLine']
To select each of the H3 elements with a class attribute value of "linstingTitleLine" that are preceding-siblings of div elements with a class attribute value of "address":
//div[#class='address']/preceding-sibling::h3[#class='listingTitleLine']