|
function to extract the nibbles from a given byte.
|
|
|
|
|
You seem to have mistaken this site for a search engine or AI chatbot.
We're more than happy to help you with problems with code you have written. But nobody here is going to do your work for you, even if you had asked politely.
Also, you've posted in the C# forum, but your message subject suggests you're working in C. Despite the similar names, those are to completely different languages. A solution for one probably won't work in the other.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
This is easily accomplished using masking and bit-shifting. Do some research on how these work and you should be able to do it, and learn something interesting along the way.
|
|
|
|
|
I have a winform project where i am using web browser control which load a site. the site has many tabular data which is a html table. user will select large text from web browser control using their mouse. the select may have many data including multiple tabular data which is nothing but a html table.
I know how to get text from selection. this is sample code which return text.
private string GetSelectedText()
{
dynamic document = webBrowser1.Document.DomDocument;
dynamic selection = document.selection;
dynamic text = selection.createRange().text;
return (string)text;
}
But i need html of selected area on web browser control programmatically. i use a code sample which suppose to return html of selected portion of web page loaded into web browser control.....but no luck.
here i am sharing that code which not working as expected. please see my code and tell me how could grab the html content from web browser control of large selection ?
here is the code which is not working.
<pre>using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace HtmlTableParser
{
public partial class Form2 : Form
{
private WebBrowser webBrowser1;
public Form2()
{
InitializeComponent();
Button btn = new Button();
btn.Text = "Test";
btn.Click += button1_Click;
this.Controls.Add(btn);
var panel = new Panel();
panel.Top = btn.Height + 2;
panel.Height = this.ClientSize.Height - btn.Height + 2;
panel.Width = this.ClientSize.Width;
panel.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
webBrowser1 = new WebBrowser();
webBrowser1.Dock = DockStyle.Fill;
webBrowser1.Url = new Uri("https://www.sec.gov/Archives/edgar/data/1108134/000110813423000018/bhlb-20230630.htm");
panel.Controls.Add(webBrowser1);
this.Controls.Add(panel);
}
private void button1_Click(object sender, EventArgs e)
{
TestSelection();
TestAllTable();
}
private void TestSelection()
{
var domdoc = this.webBrowser1.Document.DomDocument as mshtml.IHTMLDocument2;
var sel = domdoc.selection;
var range = sel.createRange();
var trange = range as mshtml.IHTMLTxtRange;
var table = GetParentTable(trange.parentElement());
if (table == null)
{
var startPointRange = trange.duplicate();
startPointRange.setEndPoint("EndToStart", trange);
var startPointTable = GetParentTable(startPointRange.parentElement());
var endPointRange = trange.duplicate();
startPointRange.setEndPoint("StartToEnd", trange);
var endPointTable = GetParentTable(endPointRange.parentElement());
if (startPointTable != null)
{
table = startPointTable;
}
else if (endPointTable != null)
{
table = endPointTable;
}
else
{
MessageBox.Show("Selection is not in Table");
return;
}
}
var tableData = TableData.GetTableData(table);
System.Diagnostics.Debug.WriteLine(tableData.ToString());
}
private mshtml.IHTMLTable GetParentTable(mshtml.IHTMLElement element)
{
var parent = element;
while (parent != null)
{
if (parent is mshtml.IHTMLTable table)
{
return table;
}
parent = parent.parentElement;
}
return null;
}
private void TestAllTable()
{
var domdoc = this.webBrowser1.Document.DomDocument as mshtml.HTMLDocument;
foreach (var table in domdoc.getElementsByTagName("table").OfType<mshtml.IHTMLTable>())
{
var tableData = TableData.GetTableData(table);
System.Diagnostics.Debug.WriteLine(tableData.ToString());
System.Diagnostics.Debug.WriteLine(new string('=', 20));
}
}
}
class TableData
{
public static TableData GetTableData(mshtml.IHTMLTable table)
{
TableData tableData = new TableData();
foreach (var tableRow in table.rows.OfType<mshtml.IHTMLTableRow>())
{
RowData rowdata = new RowData();
foreach (var tablecell in tableRow.cells.OfType<mshtml.HTMLTableCell>())
{
CellData cell = new CellData();
cell.Text = tablecell.innerText;
cell.RowSpan = tablecell.rowSpan;
cell.ColSpan = tablecell.colSpan;
rowdata.Add(cell);
}
tableData.Rows.Add(rowdata);
}
return tableData;
}
public List<RowData> Rows { get; } = new List<RowData>();
public override string ToString()
{
System.Text.StringBuilder sb = new StringBuilder();
foreach (var row in this.Rows)
{
sb.AppendLine(row.ToString());
}
return sb.ToString();
}
}
class RowData : List<CellData>
{
public override string ToString()
{
return string.Join("\t", this.Select(cell => cell.Text + new string('\t', cell.ColSpan)));
}
}
class CellData
{
public string Text { get; set; }
public int ColSpan { get; set; }
public int RowSpan { get; set; }
public override string ToString() => Text;
}
}
Here i am pasting a image which show how user will selected the portion of page.
screen shot
It is my request that for last few days i have tried many approach to get html of selection portion from web browser control....but not succeeded. please some one help me with right approach.
Thanks
|
|
|
|
|
No new code should be written today using the ancient WebBrowser control. It's an instance of Internet Explorer, and unless you edit the registry on every single computer where your code runs, it's stuck in IE7-compatability mode.
Instead, use a modern control such as WebView2[^] (Edge), CefSharp[^] (Chrome), or GeckoFX[^] (Firefox).
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
WebView not available for .net core 6 winform project. can you suggest any browser control which i can use
.net core 6 winform project ?
Thanks
|
|
|
|
|
|
The API Documentation is no help. It assumes you will use POSTMAN to access the ADP API.
I need to run daily with a C# program to pull data.
Has anyone been able to build a C# program to integrate using the ADP API?
If so, can you sure some insights?
I've successfully integrated C# with PointClickCare's API and NetHealth's API, one using XML objects and the other using JSON objects.
|
|
|
|
|
If you use Postman 10.10.6 or later, it has built-in support for generating a C# snippet to replicate the Postman request. You can generate code that uses RestSharp, or code that uses the raw HttpClient.
Open a working request in Postman, and click on the </> icon on the right-hand side.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard Deeming wrote: it has built-in support for generating a C# snippet
Well that is interesting information. I would not have even thought to look for that.
|
|
|
|
|
trying to convert dataMember from int to Color
color1.DataBindings.Add("BackColor",NavBill.DataSource,"Color1" );
Control : color1 is panel
Binding dataMember : "Color1" is columns(int,null)
How can convert dataMemer value from (int) to (Color) before assignment to property?
|
|
|
|
|
Yes you just need to use a Format event handler on the Binding object
For example
private void AddBinding() {
Binding b = color1.DataBindings.Add("BackColor", NavBill.DataSource, "Color1", true);
b.Format += PanelBackColorBinding_Format;
}
private void PanelBackColorBinding_Format(Object sender, ConvertEventArgs e) {
if (e.DesiredType == typeof(Color)) {
Int32 number = (Int32)e.Value;
Color col = GetColor(number);
e.Value = col;
}
}
Make sure that a default color is assigned to e.Value if there is any chance that the column will have missing or non convertable values.
|
|
|
|
|
Hey Everyone:
I've never done something like this before - announcing the relase of my first NuGet package. (I've had a couple of others but they were really niche.) This is an extension to the MarkDig markdown parser in .NET 6, and I used a tutorial article from here to make it happen! Thanks @cyotek for the big help!
The source code - along with my hopefully coherent documentation - is available at:
GitHub - crazycga/Evergrowth.AspForMarkDigExtension: This is the source repository for the Asp-For MarkDig Extension.[^]
The NuGet package is called "Evergrowth.AspForMarkDigExtension".
What it does:
I had a situation where a client of mine wanted to use markdown to prepare some forms for clients. Semi-static stuff. I found that when I was parsing the markdown in the controller, it wasn't getting parsed properly to make use of the 'asp-for="<model name="">"' function to build input fields. I tilted at that windmill for a time, then decided it would be a good way to grow a little as a developer and get input on my stuff... So here we are.
Thanks everyone here who - over the years - has helped me immeasurably become better at this!
-J
|
|
|
|
|
Don't post this here - forums can move pretty rapidly, and once this scrolls off the first page it gets less likely that anyone will ever see it. Plus, it's kinda rude for a "technical forum" to be plugging your work, even a free to use nuget package.
Instead, have you considered posting the Github as a Project here? Provided your documentation is indeed coherent it should be pretty easy to do: Your GitHub Project on CodeProject[^] and that is more likely to be found.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Sorry didn't mean to be rude. Was trying to thank someone for their help and inspiration. And didn't want to have a huge long lasting thing so figured posting in a forum would be good, so that it was ephemeral. For some reason I can't seem to delete to post. If you can, please do so.
|
|
|
|
|
If you want to thank someone, reply to a comment they made, or post at the bottom of the article. That way they should notice it*
Why would you want your work to be ephemeral, if you are sharing it anyway?
You can't delete your post because it has a reply - that would "orphan" the response(s) and lose the meaning of the thread (obvious if you think about it). Yes I can delete the whole thread (all Protectors can) but it's not necessary it's only "slightly rude" not "you b*****d" rude! I wouldn't worry about it, but if you still want that, just say the word.
* Some people run with emails disabled, or deliberately use a dummy email so "@" messages may not get through at all.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Since the license makes it free you can post in the Free Tools forum.
|
|
|
|
|
I want to parse multiple html table using htmlagility pack. i want to iterate in all TD and extract values.
please have a look at this url https:
the above url has many tabular data whose html tables i have to parse.
here i am pasting a small snippet of html table. please check how data is stored in this table.
<pre><table style="border-collapse:collapse;display:inline-table;margin-bottom:5pt;vertical-align:text-bottom;width:99.853%"> <tbody> <tr> <td style="width:1.0%"></td> <td style="width:71.960%"></td> <td style="width:0.1%"></td> <td style="width:0.1%"></td> <td style="width:0.532%"></td> <td style="width:0.1%"></td> <td style="width:1.0%"></td> <td style="width:11.637%"></td> <td style="width:0.1%"></td> <td style="width:0.1%"></td> <td style="width:0.532%"></td> <td style="width:0.1%"></td> <td style="width:1.0%"></td> <td style="width:11.639%"></td> <td style="width:0.1%"></td> </tr> <tr style="height:12pt"> <td colspan="3" style="padding:2px 1pt;text-align:left;vertical-align:bottom"><span style="color:#000000;font-family:'Times New Roman',sans-serif;font-size:1pt;font-weight:700;line-height:100%"> </span></td> <td colspan="3" style="padding:0 1pt"></td> <td colspan="3" rowspan="2" style="padding:2px 1pt;text-align:center;vertical-align:bottom"><span style="color:#000000;font-family:'Times New Roman',sans-serif;font-size:8pt;font-weight:700;line-height:100%">June 30,<br>2023</span></td> <td colspan="3" style="padding:0 1pt"></td> <td colspan="3" rowspan="2" style="padding:2px 1pt;text-align:center;vertical-align:bottom"><span style="color:#000000;font-family:'Times New Roman',sans-serif;font-size:8pt;font-weight:700;line-height:100%">December 31,<br>2022</span></td> </tr> <tr style="height:12pt"> <td colspan="3" style="padding:2px 1pt;text-align:left;vertical-align:bottom"><span style="color:#000000;font-family:'Times New Roman',sans-serif;font-size:8pt;font-weight:700;line-height:100%">(In thousands, except share data)</span></td> <td colspan="3" style="padding:0 1pt"></td> <td colspan="3" style="padding:0 1pt"></td> </tr> <tr> <td colspan="3" style="background-color:#cceeff;border-top:1pt solid #000000;padding:2px 1pt;text-align:left;vertical-align:bottom"><span style="color:#000000;font-family:'Times New Roman',sans-serif;font-size:10pt;font-weight:700;line-height:100%">Assets</span></td> <td colspan="3" style="background-color:#cceeff;padding:0 1pt"></td> <td colspan="3" style="background-color:#cceeff;border-top:1pt solid #000000;padding:2px 1pt;text-align:right;vertical-align:bottom"><span style="color:#000000;font-family:'Times New Roman',sans-serif;font-size:1pt;font-weight:700;line-height:100%"> </span></td> <td colspan="3" style="background-color:#cceeff;padding:0 1pt"></td> <td colspan="3" style="background-color:#cceeff;border-top:1pt solid #000000;padding:2px 1pt;text-align:right;vertical-align:bottom"><span style="color:#000000;font-family:'Times New Roman',sans-serif;font-size:1pt;font-weight:400;line-height:100%"> </span></td> </tr> <tr> <td colspan="3" style="background-color:#ffffff;padding:2px 1pt;text-align:left;vertical-align:bottom"><span style="color:#000000;font-family:'Times New Roman',sans-serif;font-size:10pt;font-weight:400;line-height:100%">Cash and due from banks</span></td> <td colspan="3" style="background-color:#ffffff;padding:0 1pt"></td> <td style="background-color:#ffffff;padding:2px 0 2px 1pt;text-align:left;vertical-align:bottom"><span style="color:#000000;font-family:'Times New Roman',sans-serif;font-size:10pt;font-weight:400;line-height:100%">$</span></td> <td style="background-color:#ffffff;padding:2px 0;text-align:right;vertical-align:bottom"> <span style="color:#000000;font-family:'Times New Roman',sans-serif;font-size:10pt;font-weight:400;line-height:100%"> <ix:nonfraction unitref="usd" contextref="c-3" decimals="-3" name="us-gaap:CashAndDueFromBanks" format="ixt:num-dot-decimal" scale="3" id="f-32">120,285</ix:nonfraction> </span> </td> <td style="background-color:#ffffff;padding:2px 1pt 2px 0;text-align:right;vertical-align:bottom"></td> <td colspan="3" style="background-color:#ffffff;padding:0 1pt"></td> <td style="background-color:#ffffff;padding:2px 0 2px 1pt;text-align:left;vertical-align:bottom"><span style="color:#000000;font-family:'Times New Roman',sans-serif;font-size:10pt;font-weight:400;line-height:100%">$</span></td> <td style="background-color:#ffffff;padding:2px 0;text-align:right;vertical-align:bottom"> <span style="color:#000000;font-family:'Times New Roman',sans-serif;font-size:10pt;font-weight:400;line-height:100%"> <ix:nonfraction unitref="usd" contextref="c-4" decimals="-3" name="us-gaap:CashAndDueFromBanks" format="ixt:num-dot-decimal" scale="3" id="f-33">145,342</ix:nonfraction> </span> </td> <td style="background-color:#ffffff;padding:2px 1pt 2px 0;text-align:right;vertical-align:bottom"></td> </tr> </tbody> </table>
Some time TD has direct data and some time TD has SPAN which has data. some time SPAN has custom tag which has data <ix:nonfraction
for a long time i am trying to loop through all TD's of all table and extract data only but getting no success.
here is my code which is trying to iterate and get data but code is not working.
<pre>var table1 = htmlDoc.DocumentNode.SelectNodes("//table");
var tbody = table1.ChildNodes["tbody"];
var lst = new List<Table1>();
foreach (var row in tbody.ChildNodes.Where(r => r.Name == "tr"))
{
var tbl1 = new Table1();
var columnsArray = row.ChildNodes.Where(c => c.Name == "td").ToArray();
for (int i = 0; i < columnsArray.Length; i++)
{
if (i == 0)
tbl1.Course = columnsArray[i].InnerText.Trim();
if (i == 1)
tbl1.Count = columnsArray[i].InnerText.Trim();
if (i == 2)
tbl1.Correct = columnsArray[i].InnerText.Trim();
}
lst.Add(tbl1);
}
Please some one guide me with a sample code which can extract data from html table TR,TD
please please need your support and help to extract data from html tables. thanks
|
|
|
|
|
Quote: but code is not working. Unfortunately that does not provide us with any useful information as to what happens when you run your code. Please edit your question, and add complete details of what is not working.
|
|
|
|
|
The name looked familiar, so I searched messages for it.
If it's the same person, and his question here fits the pattern in the days before, he's an old Assistive Nosferatu we terminated six years ago.
Just a heads up.
|
|
|
|
|
Thanks Dave. Let's see how this pans out.
|
|
|
|
|
What are you trying to say
pans out ??
|
|
|
|
|
I was replying to Dave Kreskowiak.
|
|
|
|
|
Why Dave said this ->
The name looked familiar, so I searched messages for it. what he is talking about?
|
|
|
|
|
It's a private conversation.
|
|
|
|