how to get text on web browser use xpath C#? - c#

i have html code: not attribute...
<div
style="padding: 10px 10px 20px 10px; line-height: 20px;
text-align: center;">not found
</div>
how to get text "not found" with xpath or GetElementsByTagName ("div")?

Related

C# HtmlAgilityPack Selecting url & CSS

I'm trying to grab the following data but I'm unsure how.
So, first thing I'm trying to grab is this
<div style="background-color: #eee; margin: 0px; padding-left: 15px; font-size: 12px; padding-top: 5px; border-right: 5px solid crimson !important;">
Field-Tested / Covert Rifle
I want to grab the "Field-Tested / Covert Rifle".
I did the following but got a null exception.
var wear = WebUtility.HtmlDecode(node.SelectSingleNode(#".//div[#style=""background-color: #eee; margin: 0px; padding-left: 15px; font-size: 12px; padding-top: 5px; border-right: 5px solid crimson !important;""]").InnerText);
Also the second bit of data I want to grab is
<div class="item-icon" style="background-image: url(https://steamcommunity-a.akamaihd.net/economy/image/-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KU0Zwwo4NUX4oFJZEHLbXH5ApeO4YmlhxYQknCRvCo04DEVlxkKgpot7HxfDhjxszJemkV086jloKOhcj5Nr_Yg2YfvZcg0rmXrI2n31ex8ks9Zjz2JIKdcVA4ZArRqVm-wLzn1sC8uJnMwWwj5HcoJjKuZA/256fx256f);">
I have no idea how to even attempt this, lastly is this bit of data and I have no idea as well.
<a href='/price/?market_hash_name=AK-47%20%7C%20Vulcan%20(Field-Tested)' target=_blank style='color: black;'>$23.68</a></small></p>
The reason I don't know how to do this part is because the href will be different each time. So I'm unsure how to do this...

White Lines in PDF

I'm trying to convert a html table to pdf format. When I view the table in the browsers, no white lines show up but when I export it to pdf there are white lines between every table cell and row. I've tried every css-style to solve it, but none of them work. I'm using Winnovative HTML to PDF converter. Has anyone had this problem or knows how to fix it?
.pricelistcontainer table {
width: 100%;
display: table;
padding: 0;
margin: 0;
font-size: 100%;
border-collapse: collapse;
/*margin-top: 25px;
margin-left: 52px;*/
border: none;
}
.pricelistcontainer table th {
border: none;
background: #000000;
vertical-align: top;
color: #ffffff;
font-family: arial,sans-serif;
/*line-height: 1.5;*/
font-weight: bold;
padding: 4px;
}
.pricelistcontainer table td {
/*line-height: 1.5;*/
border: none !important;
margin: 0;
background: #dae2eb;
vertical-align: middle;
font-family: arial,sans-serif;
padding-left: 2px;
color: #000;
padding-top: 4px;
padding-right: 4px;
padding-left: 4px;
}
You may use dopdf , just install it and press ctrl + p when in the web page. It will show up the print options. Choose the default printer as dopdf and save it.
As far as I know Winnovative uses the Internet Explorer rendering engine, so you might want to check what you see in IE and then adapt your CSS to that.
Alternatively you can use a solution based on webkit like wkhtmltopdf or an API that's offered at htm2pdf.

ASP.NET ConfirmButtonExtender No Background in IE

I'm using the ConfirmButtonExtender on a Cancel button. Until recently I'd been running this code in Firefox and it was displaying just right (semi transparent background, simple modal popup).
However when I switched over to test this in IE, I get the generic looking 'javascript-style-alert-box" instead.
The ModalPopupExtender seems to work in both browsers correctly and I'm guessing that's because you have more control over the CSS with that (not sure though).
Have others ran into this issue with the ConfirmButtonExtender? I just wanted to check to see if there is a fix before I switch over to the ModalPopupExtender instead.
<div class="base-container-controls-100pct">
<asp:Button ID="UxCancel" runat="server" Text="Cancel" CssClass="button-sm" OnClick="UxCancelClick" />
<asp:ConfirmButtonExtender ID="ConfirmButtonExtender2" runat="server" TargetControlID="UxCancel">
</asp:ConfirmButtonExtender>
</div>
CSS
.button, .button-sm, .button-ms, .button-md, .button-lg, .button-xl, .button-disabled, .button-status-close,
.button-grid, .button-grid-sm, .button-grid-ms, .button-grid-md, .button-grid-lg, .button-grid-xl
{
margin: 2px;
background-color: #0088C2;
color: #f2f2f2;
border-color: #DDDDDD #AAAAAA #AAAAAA #DDDDDD;
border-width: 1px;
border-style: none;
font-size: .8em;
height: 30px;
padding: 2px 12px 2px 12px;
cursor: pointer;
-moz-user-select: none;
}
.button-grid, .button-grid-sm, .button-grid-ms, .button-grid-md, .button-grid-lg, .button-grid-xl
{
height: 25px;
font-size: .8em;
}
.button-sm, .button-grid-sm
{
width: 75px;
}
.base-container-controls-100pct
{
width: 100%;
float: left;
padding: 0px;
margin: 0px;
border: none;
height: auto;
}
If it uses the standard Javascript window.confirm() (which is sounds like it does) then you have no control over the way it looks, as that is built into the browser itself. Firefox and Chrome (maybe others) changed the look of that from old popup javascript style alert box to a little nicer style a couple years ago. IE is still using the old standard style which you are seeing.
Sounds like you'll have to make a switch if you want to have more control over the look.

extract string by regular expressions in c#

I have some html files with codes like this :
<div style="border: 0px red solid; width: 633px; position: relative; margin: 0px;
float: right">
<font style="font-size: 8pt; color: Navy; font-weight: Bold;">Unit Name: </font>My Unit Name <font style="font-size: 8pt; color: Navy; font-weight: Bold;">
Manager: </font>My Manager Name <font style="font-size: 8pt;
color: Navy; font-weight: Bold;">Category: </font>My Category
</div>
<div style="border: 0px red solid; width: 122px; position: relative; margin: 0px;
padding: 0px;">
<button name="sSdewfwo87kjLKH7624QAZMLLPIdyt75576rtffTfdef22de" style="font-family: Tahoma;"
onclick="OpenMyWin2(1,843442,8445,'bf61fd588f00cbe7a37dab20c62e1c63')">
More Info</button></div>
I want to extract info in front of Category: & Manager: & Unit Name:. How can I use RegularExpression to extract those from large html file. those files may have 100 similar items.
I would recommend you consider using that tool:
http://htmlagilitypack.codeplex.com/
It allows easily parse any HTML you want.
Maybe this can help you. This uses Lookahead and Lookbehind Zero-Width Assertions.
(?<=(Category:|Manager:|Unit Name:) (</font>)?).*?(?=(&|<))
RegexBuddy ScreenShot
It is a bad idea to use regex to parse HTML code, however if you want to use regex anyway, use pattern:
>\s*Unit Name:[^>]*>([^<]+).*?>\s*Manager:[^>]*>([^<]+).*?>\s*Category:[^>]*>([^<]+)
which can be reduced to
>\s*(?:Unit Name|Manager|Category):[^>]*>([^<]+)
To trim tails replace ([^<]+) in the regex pattern with (\w+).

Image not displayed in chrome and firefox using "progid:DXImageTransform.Microsoft.AlphaImageLoader"

i am using "progid:DXImageTransform.Microsoft.AlphaImageLoader" to display iamge in div
My code is:
<body class="style_page" style="margin: 0px; background: white;" onload="onLoad()"
onunload="onUnload()" onresize="onResize()">
<div id="mediaPlayer" style="position: absolute; visibility: hidden;">
</div>
<div id="first" style="position: absolute; left: 50%; top: 0px; width: 800px; height: 600px;
font-size: 10pt; background: white;">
<div class="placeholder" style="left: 0%; top: 0%; width: 100%; height: 166%;">
<div class="outline" style="filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src='output6.jpg');">
</div>
</div>
</div>
It works fine in IE8 but doesn't work in Mozilla and google chrome
Plz help
Thanks
Mozilla, Opera, G.Chrome and other browsers doesn't support Microsoft filters for transform text and images(controls). I think that every brower producer use diferent method.
Try to find help on their sites, and you must write javascript functions to recognize browser whos load page you developed.

Categories