Microsoft SQL Server. I have an xml:
<div class="list">
<ul>
<li class="nr">5859. </li>
<li class="task">task</li>
<li class="var">Norman</li>
<li class="var">Dave</li>
</ul>
What kind select method should I use to extract result get values in one row, like:
nr, task, var1, var2
You say: I have an xml:
No! You have not! You have HTML!
Many people think, they are the same, at least they look so similar, but HTML is not XML. In your example the missing closing <div>-tag would break any XML based approach...
Taken just the list-definition you might use XML approach:
DECLARE #Xml XMl=
'<ul>
<li class="nr">5859. </li>
<li class="task">task</li>
<li class="var">Norman</li>
<li class="var">Dave</li>
</ul>'
SELECT li.value('#class','nvarchar(max)') AS NodeClass
,li.value('.','nvarchar(max)') AS NodeValue
FROM #xml.nodes('/ul/li') AS A(li)
But I'd really strongly advise not to parse HTML with SQL-Server...
If you can be sure, that the given HTML is XHTML, it is something different. XHTML is HTML with strict compliance of XML standards. In this case, and only in this case!, this is a good approach...
UPDATE: Read the XML given in comment
Two queries:
Fetch all <li> elements (if the count and naming may vary)
Fetch the values side-by-side (if the structure is fix)
Try this
DECLARE #xml XML=
N'<div class="list">
<ul>
<li class="nr">5859. </li>
<li class="task">task</li>
<li class="var">Norman</li>
<li class="var">Dave</li>
</ul>
</div>';
SELECT li.value('#class','nvarchar(max)') AS NodeClass
,li.value('.','nvarchar(max)') AS NodeValue
FROM #xml.nodes('/div/ul/li') AS A(li)
SELECT ul.value('(li[#class="nr"])[1]','nvarchar(max)') AS nr
,ul.value('(li[#class="task"])[1]','nvarchar(max)') AS task
,ul.value('(li[#class="var"])[1]','nvarchar(max)') AS var1
,ul.value('(li[#class="var"])[2]','nvarchar(max)') AS var2
FROM #xml.nodes('/div/ul') AS A(ul)
Related
quite new with Emmet and I wander if I can use nested numbering (in the example below the numbering of a depends on the numbering of parent div) to have the following results:
<div id="d1">
<a id="a11"></a>
<a id="a12"></a>
<a id="a13"></a>
...
</div>/#d1
<div id="d2">
<a id="a21"></a>
<a id="a22"></a>
<a id="a23"></a>
...
</div>/#d2
I really tried different grouping etc but cannot reach any results with the numbering $.
Thanks in advance!
This question already has an answer here:
Google search results site map?
(1 answer)
Closed 6 years ago.
I want to show my product in hierarchy in Google Search like:
I tried keyword like "how to set product list in hierarchy through meta tags", but I did not find what I want.
How can I search this type of question in Google and how to set product design in hierarchy?
As above said this is repeated question but i already told that i tried keyword like how to set product design in hierarchy because i don't know specific keyword for it and i didn't copy it.
Its called as Site Navigation in Schema Markup, which allows you to help in SEO,
Here is the code (microdata) for that
<ul itemscope itemtype="http://www.schema.org/SiteNavigationElement">
<li itemprop="name"><a itemprop="url" href="http://www.example.com/our-advantage">Our Advantage</a></li>
<li itemprop="name"><a itemprop="url" href="http://www.example.com/our-travel-experts">Travel Experts</a></li>
<li itemprop="name"><a itemprop="url" href="http://www.example.com/destinations">Destinations</a></li>
<li itemprop="name"><a itemprop="url" href="http://www.example.com/cruises">Cruises</a></li>
<li itemprop="name"><a itemprop="url" href="http://www.example.com/interests">Interests</a></li>
<li itemprop="name"><a itemprop="url" href="http://www.example.com/explore-your-world/interests/hotels-and-resorts">Hotels</a></li>
<li itemprop="name"><a itemprop="url" href="http://www.example.com/travel-guides">Travel Resources</a></li>
</ul>
and refer the below link for more information
http://searchengineland.com/schema-markup-structured-data-seo-opportunities-site-type-231077
My supervisor has recently switched us from HP-UFT to Robot with the Selenium Webdriver and I'm finding it extremely difficult to figure out how to use the driver and/or keyword framework to expand a folding tree ul/li webelement.
Below is a stripped out example of the code on the page:
<ul>
<li class="node-class open" id="i1454430045821320">
<a class="" style="" href="">
<ins> </ins>Location Header 1</a>
<ul>
<li class="node-instance leaf" id="i1454430058247421">
<a class="" style="" href="">
<ins> </ins>Location 1</a>
</li>
<li class="node-instance last leaf" id="i14545337159411690">
<a class="" style="" href="">
<ins> </ins>Location 2</a>
</li>
</ul>
</li>
<li class="node-class closed " id="i14544407827351156">
<a class="" style="" href="">
<ins> </ins>Location Header 2</a>
</li>
What I'm trying to do should be extremely simple: I want to expand a specifed closed tree structure if it's classed as closed. Beneath each branch is an optional nested branch, or a selection checkbox. My end goal is to be able to drill down to a location in the tree that the tester specifies and click the end leaf.
Using "Click Element|xpath=/ul/li[a[contains(text(),'Location Header 2')]" does expand the branch but it also selects all of the child node checkboxes.
In UFT, if I hit this kind of problem I'd simply change the parent <li> class to force it open (if I couldn't click or use any of the other methods to drill down and select).
In Robot, I can use the keyword "Get Element Attribute" to READ the class, but I don't see a keyword to CHANGE it so that idea is out. What I'm looking for is a way to expand the tree branches without inadvertently selecting all of the child nodes.
The drilling down through the tree portion I can deal with once I figure out how to open the nodes correctly but opening up the branch without potentially selecting all of the sub-items is making me pound my head into my desk.
I keep thinking that maybe I'm missing something simple. Any assistance on something that I could try would be greatly appreciated.
Figured it out! Thank you all so much for the ideas.
Click Element At Coordinates | xpath=//ul/li[a[contains(text(),'Location Header 2')] | -100 | 0
Luckily all of the ul element columns on the page have the same css style which sets them at 200px width. I figured through trial and error that the "At Coordinates" option clicks from the center of the object (and not the top left as I originally thought). I figured I'd share this in case anyone else ever has a similar problem.
I've been using zen coding and I love it. There's just one thing I can't figure out how to do (or if it's even possible.)
Say I typed:
ul#navigation>li*3
Which would output:
<ul id="navigation">
<li></li>
<li></li>
<li></li>
</ul>
How would I apply a class to a specific numbered element? Such as add a class called 'hello' to the second <li>?
You can‘t apply specific class for repeating element in this case.
However, you can insert specific class name (or any other attribute) by wrapping text with abbreviation. For example, you can wrap this text:
one
two
three
with the following abbreviation: ul#navigation>li[class=$#]*. It will produce the following output:
<ul class="navigation">
<li class="one"></li>
<li class="two"></li>
<li class="three"></li>
</ul>
Read more on https://github.com/sergeche/zen-coding/wiki/Release-Notes
I am trying to select a menu item...though xpath validates well in Xpath checker, it does not work from WebDriver ...can someone help?
I get Unable to locate element: {"method":"xpath","selector":"//a[contains(text(),'Start Loan Process')]"}
HMTL looks something like this
<div class="bd">
<ul class="first-of-type">
<li id="yui-gen7" class="yuimenuitem first-of-type" groupindex="0" index="0">
<li id="yui-gen8" class="yuimenuitem" groupindex="0" index="1">
<li id="yui-gen9" class="yuimenuitem" groupindex="0" index="2">
<li id="yui-gen10" class="yuimenuitem" groupindex="0" index="3">
<li id="yui-gen11" class="yuimenuitem" groupindex="0" index="4">
<a class="yuimenuitemlabel" href="#">Start Loan Process</a>
I have had very little luck with using the Text() part of the xpath. I would rather use the .Text (C#) or .getText() (java) method.
This is how i would write this in c#:
driver.FindElement(By.Xpath(".//*/a").Text.Contains("Start Loan Process");
The xpath part is of course debateable. It could also be: ".//div/li/a". You can use what you want.
On the other hand you can also try to use findElementsBy(By.classname("yuimenuitemlabel"))
Get them to list of web elements and then filter it using webelement.getText() method.