I have a grid like so:
<div class="div_100">
#Html.Grid(Model).Named("grid").Columns(columns =>
{
columns.Add()
.Encoded(false)
.Sanitized(false)
.SetWidth(30)
.Titled("Verzenden")
.RenderValueAs(n => Html.CheckBox("Verzonden", !n.Verzonden));
columns.Add(n => n.StartDatum).Titled("Start datum").Sortable(true).SetWidth(100);
columns.Add(n => n.EindDatum).Titled("Eind datum").Sortable(true).SetWidth(100);
columns.Add(n => n.Impact).Titled("Impact").Sortable(true).SetWidth(100);
columns.Add(n => n.NotificatieType.Type).Titled("Type").Sortable(true).SetWidth(100);
columns.Add(n => n.Omschrijving).Titled("Omschrijving").Sortable(true).SetWidth(100);
columns.Add(n => n.Diensten).Titled("Diensten").Sortable(true).SetWidth(100);
columns.Add(n => n.ID).Titled("ID").Sortable(true).SetWidth(100);
}).Filterable().SetLanguage("nl")
</div>
With quite some effort I've been able to add checkboxes.
now when i create the checkboxes i check them by default !n.Verzonden = always false
i check them true by default since it's way less likely for one to be unchecked (9 out of 10 times they need to be checked so this saves the user some time)
Now when the user is done on this page and presses a button i want all the columns.Add(n => n.ID).Titled("ID") ID's from the rows which are selected.
so how do i get all the ID's of the checked rows?
I'm currently using $.post to communicate with my controller but maybe there's a better way, for example just sending the model, i used to populate the grid with, back by a submit button or something (not that good at the whole mvc thing yet)
EDIT
The rendered html:
<div class="div_100">
<div class="grid-mvc" data-lang="nl" data-gridname="grid" data-selectable="true" data-multiplefilters="false">
<div class="grid-wrap">
<table class="table table-striped grid-table">
<thead>
<tr>
<th class="grid-header" style="width:30px;">
<div class="grid-header-title">
<span>Verzenden</span>
</div>
</th>
<th class="grid-header" style="width:100px;">
<div class="grid-filter" data-filterdata="[]" data-name="StartDatum" data-type="System.DateTime" data-widgetdata="null">
<span class="grid-filter-btn" title="Filter this column"></span>
</div>
<div class="grid-header-title">
Start datum
</div>
</th>
<th class="grid-header" style="width:100px;">
<div class="grid-filter" data-filterdata="[]" data-name="EindDatum" data-type="System.DateTime" data-widgetdata="null">
<span class="grid-filter-btn" title="Filter this column"></span>
</div>
<div class="grid-header-title">Eind datum</div>
</th>
<th class="grid-header" style="width:100px;"><div class="grid-filter" data-filterdata="[]" data-name="Impact" data-type="System.String" data-widgetdata="null"><span class="grid-filter-btn" title="Filter this column"></span></div><div class="grid-header-title">Impact</div></th>
<th class="grid-header" style="width:100px;"><div class="grid-filter" data-filterdata="[]" data-name="NotificatieType.Type" data-type="System.String" data-widgetdata="null"><span class="grid-filter-btn" title="Filter this column"></span></div><div class="grid-header-title">Type</div></th>
<th class="grid-header" style="width:100px;"><div class="grid-filter" data-filterdata="[]" data-name="Omschrijving" data-type="System.String" data-widgetdata="null"><span class="grid-filter-btn" title="Filter this column"></span></div><div class="grid-header-title">Omschrijving</div></th>
<th class="grid-header" style="width:100px;"><div class="grid-filter" data-filterdata="[]" data-name="Diensten" data-type="System.String" data-widgetdata="null"><span class="grid-filter-btn" title="Filter this column"></span></div><div class="grid-header-title">Diensten</div></th>
<th class="grid-header" style="width:100px;"><div class="grid-filter" data-filterdata="[]" data-name="ID" data-type="System.Guid" data-widgetdata="null"><span class="grid-filter-btn" title="Filter this column"></span></div><div class="grid-header-title">ID</div></th>
</tr>
</thead>
<tbody>
<tr class="grid-row ">
<td class="grid-cell" data-name="">
<input checked="checked" id="Verzonden" name="Verzonden" type="checkbox" value="true" /><input name="Verzonden" type="hidden" value="false" />
</td>
<td class="grid-cell" data-name="StartDatum">25-7-2014 10:00:00</td>
<td class="grid-cell" data-name="EindDatum">25-7-2014 11:00:00</td>
<td class="grid-cell" data-name="Impact">Volledige onderbreking</td>
<td class="grid-cell" data-name="NotificatieType.Type">onderhoud</td>
<td class="grid-cell" data-name="Omschrijving">Test</td>
<td class="grid-cell" data-name="Diensten">Volledige dienstverlening</td>
<td class="grid-cell" data-name="ID">3a2a53b9-d92a-4504-874d-5a901ad01041</td>
</tr>
<tr class="grid-row ">
<td class="grid-cell" data-name=""><input checked="checked" id="Verzonden" name="Verzonden" type="checkbox" value="true" /><input name="Verzonden" type="hidden" value="false" /></td>
<td class="grid-cell" data-name="StartDatum">25-7-2014 12:00:00</td>
<td class="grid-cell" data-name="EindDatum">25-7-2014 13:00:00</td>
<td class="grid-cell" data-name="Impact">Volledige onderbreking</td>
<td class="grid-cell" data-name="NotificatieType.Type">onderhoud</td>
<td class="grid-cell" data-name="Omschrijving">Test</td>
<td class="grid-cell" data-name="Diensten">Volledige dienstverlening</td>
<td class="grid-cell" data-name="ID">4c499f6c-53c8-49e0-b529-8b045819be10</td>
</tr>
<tr class="grid-row ">
<td class="grid-cell" data-name=""><input checked="checked" id="Verzonden" name="Verzonden" type="checkbox" value="true" /><input name="Verzonden" type="hidden" value="false" /></td>
<td class="grid-cell" data-name="StartDatum">25-7-2014 13:00:00</td>
<td class="grid-cell" data-name="EindDatum">25-7-2014 15:00:00</td>
<td class="grid-cell" data-name="Impact">Volledige onderbreking</td>
<td class="grid-cell" data-name="NotificatieType.Type">onderhoud</td>
<td class="grid-cell" data-name="Omschrijving"></td>
<td class="grid-cell" data-name="Diensten">Volledige dienstverlening</td>
<td class="grid-cell" data-name="ID">977885c5-4c12-431b-ab72-59383b1824c6</td>
</tr>
<tr class="grid-row ">
<td class="grid-cell" data-name=""><input checked="checked" id="Verzonden" name="Verzonden" type="checkbox" value="true" /><input name="Verzonden" type="hidden" value="false" /></td>
<td class="grid-cell" data-name="StartDatum">28-7-2014 10:00:00</td>
<td class="grid-cell" data-name="EindDatum">28-7-2014 11:00:00</td>
<td class="grid-cell" data-name="Impact">Gedeeltelijke onderbreking van de dienstverlening</td>
<td class="grid-cell" data-name="NotificatieType.Type">onderhoud</td>
<td class="grid-cell" data-name="Omschrijving">Update print servers</td>
<td class="grid-cell" data-name="Diensten">Gedeeltelijke service</td>
<td class="grid-cell" data-name="ID">af4ed8cb-d033-47a4-96ae-f379bb484532</td>
</tr>
<tr class="grid-row ">
<td class="grid-cell" data-name=""><input checked="checked" id="Verzonden" name="Verzonden" type="checkbox" value="true" /><input name="Verzonden" type="hidden" value="false" /></td>
<td class="grid-cell" data-name="StartDatum">30-7-2014 10:00:00</td>
<td class="grid-cell" data-name="EindDatum">30-7-2014 14:00:00</td>
<td class="grid-cell" data-name="Impact">Gedeeltelijke onderbreking van de dienstverlening</td>
<td class="grid-cell" data-name="NotificatieType.Type">onderhoud</td>
<td class="grid-cell" data-name="Omschrijving">Niets</td>
<td class="grid-cell" data-name="Diensten">Volledige service</td>
<td class="grid-cell" data-name="ID">f2388fba-27ab-417a-ab39-a221d9d82fd3</td>
</tr>
<tr class="grid-row ">
<td class="grid-cell" data-name=""><input checked="checked" id="Verzonden" name="Verzonden" type="checkbox" value="true" /><input name="Verzonden" type="hidden" value="false" /></td>
<td class="grid-cell" data-name="StartDatum">30-7-2014 10:00:00</td>
<td class="grid-cell" data-name="EindDatum">30-7-2014 14:00:00</td>
<td class="grid-cell" data-name="Impact">Gedeeltelijke onderbreking van de dienstverlening</td>
<td class="grid-cell" data-name="NotificatieType.Type">onderhoud</td>
<td class="grid-cell" data-name="Omschrijving">Niets</td>
<td class="grid-cell" data-name="Diensten">Volledige service</td>
<td class="grid-cell" data-name="ID">3232fc33-0f82-4f76-a323-7ee988c4069a</td>
</tr>
<tr class="grid-row ">
<td class="grid-cell" data-name=""><input checked="checked" id="Verzonden" name="Verzonden" type="checkbox" value="true" /><input name="Verzonden" type="hidden" value="false" /></td>
<td class="grid-cell" data-name="StartDatum">30-7-2014 10:00:00</td>
<td class="grid-cell" data-name="EindDatum">30-7-2014 14:00:00</td>
<td class="grid-cell" data-name="Impact">Gedeeltelijke onderbreking van de dienstverlening</td>
<td class="grid-cell" data-name="NotificatieType.Type">onderhoud</td>
<td class="grid-cell" data-name="Omschrijving">Niets</td>
<td class="grid-cell" data-name="Diensten">Volledige service</td>
<td class="grid-cell" data-name="ID">b9c2ff88-f469-49f0-a23c-86ddb8bf7808</td>
</tr>
<tr class="grid-row ">
<td class="grid-cell" data-name=""><input checked="checked" id="Verzonden" name="Verzonden" type="checkbox" value="true" /><input name="Verzonden" type="hidden" value="false" /></td>
<td class="grid-cell" data-name="StartDatum">31-7-2014 11:00:00</td>
<td class="grid-cell" data-name="EindDatum">31-7-2014 14:00:00</td>
<td class="grid-cell" data-name="Impact">Gedeeltelijke onderbreking van de dienstverlening</td>
<td class="grid-cell" data-name="NotificatieType.Type">onderhoud</td>
<td class="grid-cell" data-name="Omschrijving">Niets</td>
<td class="grid-cell" data-name="Diensten">Volledige service</td>
<td class="grid-cell" data-name="ID">ecaa15da-0b91-4410-97ad-ba58148ebe4f</td>
</tr>
</tbody>
</table>
</div>
</div>
Try
$('input:checked').each(function () {
var row = $(this).closest('tr');
var ID = row.children('td').eq(7).text();
alert(ID); // for testing - don't know what you want to do with the ID's
});
Related
I have string html, I want to get all id name of tag in string html.
get string html in file text:
<tr>
<td class="X8">
</td>
<td colspan="6" class="X9"></td>
<td colspan="4" class="X12" id="closedate">
</td>
<td colspan="6" class="X9"></td>
<td colspan="4" class="X12" id="startdate">
</td>
<td class="X8">
</td>
<td class="X8" colspan="3">
</td>
<td class="X8">
</td>
<td colspan="9" class="X9"></td>
<td colspan="6" class="X15" id="totalpayment"></td>
<td class="X8">
</td>
<td class="X8">
</td>
</tr>
<tr>
<td class="X17">
</td>
<td class="X17" colspan="8">
</td>
<td class="X17" colspan="33">
</td>
<td class="X17">
</td>
</tr>
<tr>
<td class="X17">
</td>
<td class="X17" colspan="8">
<td class="X17" colspan="16">
</td>
<td class="X17">
</td>
<td colspan="9" class="X20"></td>
<td colspan="6" class="X23" id="approvaldate"></td>
<td class="X17">
</td>
<td class="X17">
</td>
</tr>
expected results:
closedate, startdate,totalpayment, approvaldate.
Then I want to set inner text for id name tag
(Ex:<td colspan="6" class="X23" id="approvaldate">2018/07/18</td>)
Using c#.Help me, please. Thanks a lot.
What I am understood from your question is you need the id of all in string simple Example Created for you
<form id="form1" runat="server">
<input id="Name" type="text" name="Full Name" runat="server" />
<input id="Email" type="text" name="Email Address" runat="server" />
<input id="Phone" type="text" name="Phone Number" runat="server" />
</form>
foreach (var control in Page.Form.Controls)
{
if (control is HtmlInputControl)
{
var htmlInputControl = control as HtmlInputControl;
string controlName = htmlInputControl.Name;
string controlId = htmlInputControl.ID;
}
}
Another Approach:-
HtmlElement table = testWebBrowser.Document.GetElementById("TableID");
if (table != null)
{
foreach (HtmlElement row in table.GetElementsByTagName("TR"))
{
// ...
}
}
I am facing an error in generating a proper PDF Document. the code i have, can generate a pdf document, it can download the document, but the issue is i cannot view the view the document. This is the Page I am trying to export to pdf.
Here is my code so far:
ASPX:
<asp:Button ID="btnDownload" CssClass="btn" runat="server" Text="Download Invoice" OnClick="btnDownload_Click" />
<asp:Panel ID="pnl" runat="server">
<div id="page-wrap">
<textarea id="header" style="height: 30px">PAYMENT DETAILS</textarea>
<div id="identity">
<textarea style="background-color: #F7F7F7;" readonly="readonly" id="address">My Name
My Street Address
Phone: 111-111-111</textarea>
<div id="logo">
<div id="logoctr">
</div>
<div id="logohelp">
<input id="imageloc" readonly="readonly" type="text" size="50" value="" /><br />
(max width: 540px, max height: 100px)
</div>
<img id="image" src="images/logo.png" alt="logo" />
</div>
</div>
<div style="clear: both"></div>
<div id="customer">
<textarea id="tbCustomer" readonly="readonly" runat="server"></textarea>
<table id="meta">
<tr>
<td class="meta-head">Payment ID</td>
<td>
<textarea readonly="readonly" runat="server" id="tbPID"></textarea></td>
</tr>
<tr>
<td class="meta-head">Date</td>
<td>
<textarea id="date" readonly="readonly" runat="server"></textarea></td>
</tr>
<tr>
<td class="meta-head">Amount Due</td>
<td>
<div class="due">
$
<asp:Label ID="lblTotal" runat="server" Text="Total"></asp:Label>
</div>
</td>
</tr>
</table>
</div>
<table id="items">
<tr>
<th>Property Title</th>
<th>Description</th>
<th>Status</th>
<th>Invoiced By</th>
<th>Total Payment</th>
</tr>
<tr class="item-row">
<td class="item-name">
<div class="delete-wpr">
<textarea readonly="readonly" id="tbTitle" runat="server"></textarea>
</div>
</td>
<td class="description">
<div contenteditable="true" id="tbDetail" class="blank" runat="server">
</div>
</td>
<td>
<textarea id="tbStatus" runat="server" readonly="readonly">PAID</textarea></td>
<td>
<textarea class="qty" readonly="readonly" id="tbInvoicedBy" runat="server"></textarea></td>
<td><span class="price">$
<asp:Label ID="tbTotal1" runat="server" Text="Total"></asp:Label></span></td>
</tr>
<tr>
<td colspan="2" class="blank"></td>
<td colspan="2" class="total-line">Vaccant</td>
<td class="total-value">
<div id="subtotal">$<asp:Label ID="lblVaccant" runat="server" Text=""></asp:Label></div>
</td>
</tr>
<tr>
<td colspan="2" class="blank"></td>
<td colspan="2" class="total-line">Maintainance</td>
<td class="total-value">
<div id="total">$<asp:Label ID="lblMaintainance" runat="server" Text=""></asp:Label></div>
</td>
</tr>
<tr>
<td colspan="2" class="blank"></td>
<td colspan="2" class="total-line">Property Insurance</td>
<td class="total-value">
<div id="Insurance">$<asp:Label ID="lblInsurance" runat="server" Text=""></asp:Label></div>
</td>
</tr>
<tr>
<td colspan="2" class="blank"></td>
<td colspan="2" class="total-line">Dewa Bill</td>
<td class="total-value">
<div id="dewa">$<asp:Label ID="lblDewa" runat="server" Text=""></asp:Label></div>
</td>
</tr>
<tr>
<td colspan="2" class="blank"></td>
<td colspan="2" class="total-line">Furnishing Cost</td>
<td class="total-value">
<div id="FurnishingCost">$<asp:Label ID="lblFurnishing" runat="server" Text=""></asp:Label></div>
</td>
</tr>
<tr>
<td colspan="2" class="blank"></td>
<td colspan="2" class="total-line">Cleaning Fees</td>
<td class="total-value">
<div id="CleaningFees">$<asp:Label ID="lblCleaning" runat="server" Text=""></asp:Label></div>
</td>
</tr>
<tr>
<td colspan="2" class="blank"></td>
<td colspan="2" class="total-line">House Keeping</td>
<td class="total-value">
<div id="HouseKeeping">$<asp:Label ID="lblHouseKeeping" runat="server" Text=""></asp:Label></div>
</td>
</tr>
<tr>
<td colspan="2" class="blank"></td>
<td colspan="2" class="total-line">Next Rent Due</td>
<td class="total-value">
<div id="paid">$<asp:Label ID="lblNextRent" runat="server" Text=""></asp:Label></div>
</td>
</tr>
<tr>
<td colspan="2" class="blank"></td>
<td colspan="2" class="total-line">Rental Comission</td>
<td class="total-value">
<div id="RentalComission">$<asp:Label ID="lblRentalComission" runat="server" Text=""></asp:Label></div>
</td>
</tr>
<tr>
<td colspan="2" class="blank"></td>
<td colspan="2" class="total-line">Credit Card Fees</td>
<td class="total-value">
<div id="CreditCardFees">$<asp:Label ID="lblCreditCardFees" runat="server" Text=""></asp:Label></div>
</td>
</tr>
<tr>
<td colspan="2" class="blank"></td>
<td colspan="2" class="total-line">Pest Control</td>
<td class="total-value">
<div id="PestControl">$<asp:Label ID="lblPestControl" runat="server" Text=""></asp:Label></div>
</td>
</tr>
<tr>
<td colspan="2" class="blank"></td>
<td colspan="2" class="total-line">Chillar Utilities</td>
<td class="total-value">
<div id="ChillarUtilities">$<asp:Label ID="lblChillarUtilities" runat="server" Text=""></asp:Label></div>
</td>
</tr>
<tr>
<td colspan="2" class="blank"></td>
<td colspan="2" class="total-line">Du, etisilate wifi</td>
<td class="total-value">
<div id="DuEtisilatewifi">$<asp:Label ID="lblDuEtisilateWifi" runat="server" Text=""></asp:Label></div>
</td>
</tr>
<tr>
<td colspan="2" class="blank"></td>
<td colspan="2" class="total-line balance">Total Payment</td>
<td class="total-value balance">
<div class="due">$<asp:Label ID="lblTotal2" runat="server" Text=""></asp:Label></div>
</td>
</tr>
</table>
<div id="terms">
<h5>Terms</h5>
<textarea readonly="readonly">These payment details are final and non negotiable.</textarea>
</div>
</div>
</asp:Panel>
ASPX.CS
public void ExportToPDF()
{
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=Panel.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
pnl.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
sw.Close();
htmlparser.Close();
Response.Write(pdfDoc);
Response.End();
}
also it says the HTMLWorker class is obsolete.
I have a specific record I am attempting to select out of the data grid. Can some help with the XPath to get to that record.
I have tried the following but it doesn't work:
var elementEdit = driver.FindElement(By.XPath(".//tbody[#ClassName='ng-scope']/tr[#ng-binding='" + Username + "']"));
Here is the HTML code:
<tbody>
<!-- ngRepeat: user in model -->
<tr class="ng-scope" ng-repeat="user in model">
<td class="ng-binding">pppp</td>
<td class="ng-binding">ppp</td>
<td class="ng-binding">joetester24</td>
<td class="ng-binding">+16195555555</td>
<td class="ng-binding">
<img class="map-icon" src="../../media/images/google-maps-icon.png" ng-click="viewMap(user.lastKnownPosition.lat, user.lastKnownPosition.lon)">0, 0
</td>
<td class="text-center" ng-click="open(user)"><span class="fa fa-edit"></span>
</td>
</tr>
<!-- end ngRepeat: user in model -->
<tr class="ng-scope" ng-repeat="user in model">
<td class="ng-binding">gg</td>
<td class="ng-binding">ggg</td>
<td class="ng-binding">joetester99 ggff66</td>
<td class="ng-binding">+18587660891</td>
<td class="ng-binding">
<img class="map-icon" src="../../media/images/google-maps-icon.png" ng-click="viewMap(user.lastKnownPosition.lat, user.lastKnownPosition.lon)">0, 0
</td>
<td class="text-center" ng-click="open(user)"><span class="fa fa-edit"></span>
</td>
</tr>
<!-- end ngRepeat: user in model -->
<tr class="ng-scope" ng-repeat="user in model">
<td class="ng-binding">Evelina</td>
<td class="ng-binding">Papantoniou</td>
<td class="ng-binding">joetester996</td>
<td class="ng-binding">+12015555555</td>
<td class="ng-binding">
<img class="map-icon" src="../../media/images/google-maps-icon.png" ng-click="viewMap(user.lastKnownPosition.lat, user.lastKnownPosition.lon)">0, 0
</td>
<td class="text-center" ng-click="open(user)"><span class="fa fa-edit"></span>
</td>
</tr>
<!-- end ngRepeat: user in model -->
<tr class="ng-scope" ng-repeat="user in model">
<td class="ng-binding">Parvati</td>
<td class="ng-binding">Shallow</td>
<td class="ng-binding">joetester990</td>
<td class="ng-binding">+12015555555</td>
<td class="ng-binding">
<img class="map-icon" src="../../media/images/google-maps-icon.png" ng-click="viewMap(user.lastKnownPosition.lat, user.lastKnownPosition.lon)">0, 0
</td>
<td class="text-center" ng-click="open(user)"><span class="fa fa-edit"></span>
</td>
</tr>
<!-- end ngRepeat: user in model -->
<tr class="ng-scope" ng-repeat="user in model">
<td class="ng-binding">Doutzen</td>
<td class="ng-binding">Kroes</td>
<td class="ng-binding">joetester998</td>
<td class="ng-binding">+12015555555</td>
<td class="ng-binding">
<img class="map-icon" src="../../media/images/google-maps-icon.png" ng-click="viewMap(user.lastKnownPosition.lat, user.lastKnownPosition.lon)">0, 0
</td>
<td class="text-center" ng-click="open(user)"><span class="fa fa-edit"></span>
</td>
</tr>
<!-- end ngRepeat: user in model -->
<tr class="ng-scope" ng-repeat="user in model">
<td class="ng-binding">Evelina</td>
<td class="ng-binding">Papantoniou</td>
<td class="ng-binding">joetester996</td>
<td class="ng-binding">+12015555555</td>
<td class="ng-binding">
<img class="map-icon" src="../../media/images/google-maps-icon.png" ng-click="viewMap(user.lastKnownPosition.lat, user.lastKnownPosition.lon)">0, 0
</td>
<td class="text-center" ng-click="open(user)"><span class="fa fa-edit"></span>
</td>
</tr>
<!-- end ngRepeat: user in model -->
<tr class="ng-scope" ng-repeat="user in model">
<td class="ng-binding">Tereza</td>
<td class="ng-binding">Benesova</td>
<td class="ng-binding">joetester995</td>
<td class="ng-binding">+17036928692</td>
<td class="ng-binding">
<img class="map-icon" src="../../media/images/google-maps-icon.png" ng-click="viewMap(user.lastKnownPosition.lat, user.lastKnownPosition.lon)">0, 0
</td>
<td class="text-center" ng-click="open(user)"><span class="fa fa-edit"></span>
</td>
</tr>
<!-- end ngRepeat: user in model -->
<tr class="ng-scope" ng-repeat="user in model">
<td class="ng-binding">Ashley</td>
<td class="ng-binding">Degenford</td>
<td class="ng-binding">joetester992</td>
<td class="ng-binding">+17036976251</td>
<td class="ng-binding">
<img class="map-icon" src="../../media/images/google-maps-icon.png" ng-click="viewMap(user.lastKnownPosition.lat, user.lastKnownPosition.lon)">0, 0
</td>
<td class="text-center" ng-click="open(user)"><span class="fa fa-edit"></span>
</td>
</tr>
<!-- end ngRepeat: user in model -->
<tr class="ng-scope" ng-repeat="user in model">
<td class="ng-binding">Joe</td>
<td class="ng-binding">Tester114</td>
<td class="ng-binding">joetester114</td>
<td class="ng-binding">+16195551212</td>
<td class="ng-binding">
<img class="map-icon" src="../../media/images/google-maps-icon.png" ng-click="viewMap(user.lastKnownPosition.lat, user.lastKnownPosition.lon)">0, 0
</td>
<td class="text-center" ng-click="open(user)"><span class="fa fa-edit"></span>
</td>
</tr>
<!-- end ngRepeat: user in model -->
<tr class="ng-scope" ng-repeat="user in model">
<td class="ng-binding">Jodi Ann</td>
<td class="ng-binding">Paterson</td>
<td class="ng-binding">joetester994</td>
<td class="ng-binding">+17036951997</td>
<td class="ng-binding">
<img class="map-icon" src="../../media/images/google-maps-icon.png" ng-click="viewMap(user.lastKnownPosition.lat, user.lastKnownPosition.lon)">0, 0
</td>
<td class="text-center" ng-click="open(user)"><span class="fa fa-edit"></span>
</td>
</tr>
<!-- end ngRepeat: user in model -->
<tr class="ng-scope" ng-repeat="user in model">
<td class="ng-binding">Leilani</td>
<td class="ng-binding">Dowding</td>
<td class="ng-binding">joetester993</td>
<td class="ng-binding">+17036149998</td>
<td class="ng-binding">
<img class="map-icon" src="../../media/images/google-maps-icon.png" ng-click="viewMap(user.lastKnownPosition.lat, user.lastKnownPosition.lon)">0, 0
</td>
<td class="text-center" ng-click="open(user)"><span class="fa fa-edit"></span>
</td>
</tr>
<!-- end ngRepeat: user in model -->
<tr class="ng-scope" ng-repeat="user in model">
<td class="ng-binding">Naureen</td>
<td class="ng-binding">Zaim</td>
<td class="ng-binding">joetester991</td>
<td class="ng-binding">+17036957508</td>
<td class="ng-binding">
<img class="map-icon" src="../../media/images/google-maps-icon.png" ng-click="viewMap(user.lastKnownPosition.lat, user.lastKnownPosition.lon)">0, 0
</td>
<td class="text-center" ng-click="open(user)"><span class="fa fa-edit"></span>
</td>
</tr>
<!-- end ngRepeat: user in model -->
<tr class="ng-scope" ng-repeat="user in model">
<td class="ng-binding">Joe</td>
<td class="ng-binding">Tester445</td>
<td class="ng-binding">joetester445</td>
<td class="ng-binding">+16195551212</td>
<td class="ng-binding">
<img class="map-icon" src="../../media/images/google-maps-icon.png" ng-click="viewMap(user.lastKnownPosition.lat, user.lastKnownPosition.lon)">0, 0
</td>
<td class="text-center" ng-click="open(user)"><span class="fa fa-edit"></span>
</td>
</tr>
<!-- end ngRepeat: user in model -->
<tr class="ng-scope" ng-repeat="user in model">
<td class="ng-binding">Joe</td>
<td class="ng-binding">Tester229</td>
<td class="ng-binding">joetester229</td>
<td class="ng-binding">+16195551212</td>
<td class="ng-binding">
<img class="map-icon" src="../../media/images/google-maps-icon.png" ng-click="viewMap(user.lastKnownPosition.lat, user.lastKnownPosition.lon)">0, 0
</td>
<td class="text-center" ng-click="open(user)"><span class="fa fa-edit"></span>
</td>
</tr>
<!-- end ngRepeat: user in model -->
<tr class="ng-scope" ng-repeat="user in model">
<td class="ng-binding">Juliet</td>
<td class="ng-binding">Cariaga</td>
<td class="ng-binding">joetester997</td>
<td class="ng-binding">+17032715280</td>
<td class="ng-binding">
<img class="map-icon" src="../../media/images/google-maps-icon.png" ng-click="viewMap(user.lastKnownPosition.lat, user.lastKnownPosition.lon)">0, 0
</td>
<td class="text-center" ng-click="open(user)"><span class="fa fa-edit"></span>
</td>
</tr>
<!-- end ngRepeat: user in model -->
<tr class="ng-scope" ng-repeat="user in model">
<td class="ng-binding">Joe</td>
<td class="ng-binding">Tester825</td>
<td class="ng-binding">joetester825</td>
<td class="ng-binding">+16195551212</td>
<td class="ng-binding">
<img class="map-icon" src="../../media/images/google-maps-icon.png" ng-click="viewMap(user.lastKnownPosition.lat, user.lastKnownPosition.lon)">0, 0
</td>
<td class="text-center" ng-click="open(user)"><span class="fa fa-edit"></span>
</td>
</tr>
<!-- end ngRepeat: user in model -->
<tr class="ng-scope" ng-repeat="user in model">
<td class="ng-binding">shdh</td>
<td class="ng-binding">dff</td>
<td class="ng-binding">joetesteroqur</td>
<td class="ng-binding">+16195553164</td>
<td class="ng-binding">
<img class="map-icon" src="../../media/images/google-maps-icon.png" ng-click="viewMap(user.lastKnownPosition.lat, user.lastKnownPosition.lon)">0, 0
</td>
<td class="text-center" ng-click="open(user)"><span class="fa fa-edit"></span>
</td>
</tr>
<!-- end ngRepeat: user in model -->
<tr class="ng-scope" ng-repeat="user in model">
<td class="ng-binding">hdjd</td>
<td class="ng-binding">xddd</td>
<td class="ng-binding">joetester0183</td>
<td class="ng-binding">+16195553164</td>
<td class="ng-binding">
<img class="map-icon" src="../../media/images/google-maps-icon.png" ng-click="viewMap(user.lastKnownPosition.lat, user.lastKnownPosition.lon)">0, 0
</td>
<td class="text-center" ng-click="open(user)"><span class="fa fa-edit"></span>
</td>
</tr>
<!-- end ngRepeat: user in model -->
<tr class="ng-scope" ng-repeat="user in model">
<td class="ng-binding">djd</td>
<td class="ng-binding">dff</td>
<td class="ng-binding">joetesterm</td>
<td class="ng-binding">+16195553164</td>
<td class="ng-binding">
<img class="map-icon" src="../../media/images/google-maps-icon.png" ng-click="viewMap(user.lastKnownPosition.lat, user.lastKnownPosition.lon)">0, 0
</td>
<td class="text-center" ng-click="open(user)"><span class="fa fa-edit"></span>
</td>
</tr>
<!-- end ngRepeat: user in model -->
<tr class="ng-scope" ng-repeat="user in model">
<td class="ng-binding">gf</td>
<td class="ng-binding">ff</td>
<td class="ng-binding">joetesterqww</td>
<td class="ng-binding">+16195553164</td>
<td class="ng-binding">
<img class="map-icon" src="../../media/images/google-maps-icon.png" ng-click="viewMap(user.lastKnownPosition.lat, user.lastKnownPosition.lon)">0, 0
</td>
<td class="text-center" ng-click="open(user)"><span class="fa fa-edit"></span>
</td>
</tr>
<!-- end ngRepeat: user in model -->
<tr class="ng-scope" ng-repeat="user in model">
<td class="ng-binding">hhh</td>
<td class="ng-binding">aaaa</td>
<td class="ng-binding">joetester6p</td>
<td class="ng-binding">+16195553164</td>
<td class="ng-binding">
<img class="map-icon" src="../../media/images/google-maps-icon.png" ng-click="viewMap(user.lastKnownPosition.lat, user.lastKnownPosition.lon)">0, 0
</td>
<td class="text-center" ng-click="open(user)"><span class="fa fa-edit"></span>
</td>
</tr>
<!-- end ngRepeat: user in model -->
<tr class="ng-scope" ng-repeat="user in model">
<td class="ng-binding">Parvati</td>
<td class="ng-binding">Shallow</td>
<td class="ng-binding">joetester990</td>
<td class="ng-binding">+12015555555</td>
<td class="ng-binding">
<img class="map-icon" src="../../media/images/google-maps-icon.png" ng-click="viewMap(user.lastKnownPosition.lat, user.lastKnownPosition.lon)">0, 0
</td>
<td class="text-center" ng-click="open(user)"><span class="fa fa-edit"></span>
</td>
</tr>
<!-- end ngRepeat: user in model -->
<tr class="ng-scope" ng-repeat="user in model">
<td class="ng-binding">hshs</td>
<td class="ng-binding">fff</td>
<td class="ng-binding">joetesterhdhd</td>
<td class="ng-binding">+16195554785</td>
<td class="ng-binding">
<img class="map-icon" src="../../media/images/google-maps-icon.png" ng-click="viewMap(user.lastKnownPosition.lat, user.lastKnownPosition.lon)">0, 0
</td>
<td class="text-center" ng-click="open(user)"><span class="fa fa-edit"></span>
</td>
</tr>
<!-- end ngRepeat: user in model -->
<tr class="ng-scope" ng-repeat="user in model">
<td class="ng-binding">test</td>
<td class="ng-binding">test</td>
<td class="ng-binding">joetester234</td>
<td class="ng-binding">+16195551207</td>
<td class="ng-binding">
<img class="map-icon" src="../../media/images/google-maps-icon.png" ng-click="viewMap(user.lastKnownPosition.lat, user.lastKnownPosition.lon)">0, 0
</td>
<td class="text-center" ng-click="open(user)"><span class="fa fa-edit"></span>
</td>
</tr>
<!-- end ngRepeat: user in model -->
<tr class="ng-scope" ng-repeat="user in model">
<td class="ng-binding">test</td>
<td class="ng-binding">test</td>
<td class="ng-binding">joetester789</td>
<td class="ng-binding">+16195551207</td>
<td class="ng-binding">
<img class="map-icon" src="../../media/images/google-maps-icon.png" ng-click="viewMap(user.lastKnownPosition.lat, user.lastKnownPosition.lon)">0, 0
</td>
<td class="text-center" ng-click="open(user)"><span class="fa fa-edit"></span>
</td>
</tr>
<!-- end ngRepeat: user in model -->
</tbody>
For example if you want to select joetester24
then the xpath is as follows
//tr[#class='ng-scope']/td[text()='joetester24']
You can try using looping to traverse each element.
var trr = driver.findElements(By.XPath("*//tr[#class='ng-scope']"));
forEach(Iwebelement tr in trr){
var tdd = tr.driver.findElements(By.XPath("*//td[#class='ng-binding']"));
forEach(Iwebelement td in tdd){
if(td.text == "YOUR_MATCHING_TEXT"){// do operations}
// else continue;
}
}
this will take look on each element of your HTML DOM for till your interested element get found
![enter image description here][1]In my application, I have used the MVC telerik grid, bounded with input textboxes. While I run the application in Internet Explorer and the Chrome browser, the tab indexing in working fine and control is moving from one textbox to the other. But when using the Firefox browser, the tab indexing is moving from table row to table row and highlighting the complete cell.
Please help me to fix this.
<div class="appln-cnt-c2">
<div class="frm-fldrow">
<div class="appln-txtrow" style="width: 800px; position: relative; left: 45px;">
#{
Html.Telerik().Grid(Model.FacultyCompositions)
.Name("FacultyComositionGrid")
.DataKeys(keys => keys.Add(m => m.FacultyCompositionPK))
.ClientEvents(events => events.OnComplete("FacultyComositionGrid_onComplete").OnError("FacultyComositionGrid_onError").OnDelete("OnDelete").OnEdit("OnEdit"))
.Columns(columns =>
{
columns.Bound(m => m.EthnicityDescription)
.Title("<strong>Ethnicity</strong>").Width(180).Filterable(false).Sortable(false).ReadOnly(true);
columns.Template(#<text>
<table cellspacing="0" cellpadding="0">
<tr id="data">
<td>
<input type="text" class="FacultyCompositionTextbox" value="#item.FCYear1Male" #(Model.ReadOnlyFacultyCompositionNew[0])#(item.DisableCalculatedRow) maxlength="4" onkeypress="return IsNumeric(event);" />
</td>
<td>
<input class="FacultyCompositionTextbox" type="text" value="#item.FCYear1Female" #(Model.ReadOnlyFacultyCompositionNew[0]) #(item.DisableCalculatedRow) maxlength="4" onkeypress="return IsNumeric(event);" />
<input class="FacultyCompositionTextbox" type="hidden" value="#item.EthnicityPK" />
</td>
</tr>
</table>
</text>)
.HeaderTemplate(
#<text>
<table cellspacing="0" cellpadding="0">
#if (Model.FacultyCompositionColumnHeader[0] != "")
{
<tr>
<td colspan="2"><strong>#Model.FacultyCompositionColumnHeader[0]</strong></td>
</tr>
<tr>
<td><span>M</span></td>
<td><span>F</span></td>
</tr>
}
else
{
<tr>
<td colspan="2"><strong></strong></td>
</tr>
<tr>
<td><span></span></td>
<td><span></span></td>
</tr>
}
</table>
</text>).Width(20);
columns.Template(#<text>
<table cellspacing="0" cellpadding="0">
<tr id="data">
<td>
<input type="text" class="FacultyCompositionTextbox" value="#item.FCYear2Male" #(Model.ReadOnlyFacultyCompositionNew[1]) #(item.DisableCalculatedRow) maxlength="4" onkeypress="return IsNumeric(event);" />
</td>
<td>
<div style="position: relative;">
<input class="FacultyCompositionTextbox" type="text" value="#item.FCYear2Female" #(Model.ReadOnlyFacultyCompositionNew[1]) #(item.DisableCalculatedRow) maxlength="4" onkeypress="return IsNumeric(event);" />
<input class="FacultyCompositionTextbox" type="hidden" value="#item.EthnicityPK" />
</div>
</td>
</tr>
</table>
</text>)
.HeaderTemplate(
#<text>
<table cellspacing="0" cellpadding="0">
#if (Model.FacultyCompositionColumnHeader[1] != "")
{
<tr>
<td colspan="2"><strong>#Model.FacultyCompositionColumnHeader[1]</strong></td>
</tr>
<tr>
<td><span>M</span></td>
<td><span>F</span></td>
</tr>
}
else
{
<tr>
<td colspan="2"><strong></strong></td>
</tr>
<tr>
<td><span></span></td>
<td><span></span></td>
</tr>
}
</table>
</text>).Width(20);
columns.Template(#<text>
<table cellspacing="0" cellpadding="0">
<tr id="data">
<td>
<input type="text" class="FacultyCompositionTextbox" value="#item.FCYear3Male" #(Model.ReadOnlyFacultyCompositionNew[2]) #(item.DisableCalculatedRow) maxlength="4" onkeypress="return IsNumeric(event);" />
</td>
<td>
<input class="FacultyCompositionTextbox" type="text" value="#item.FCYear3Female" #(Model.ReadOnlyFacultyCompositionNew[2]) #(item.DisableCalculatedRow) maxlength="4" onkeypress="return IsNumeric(event);" />
<input class="FacultyCompositionTextbox" type="hidden" value="#item.EthnicityPK" /></td>
</tr>
</table>
</text>)
.HeaderTemplate(
#<text>
<table cellspacing="0" cellpadding="0">
#if (Model.FacultyCompositionColumnHeader[2] != "")
{
<tr>
<td colspan="2"><strong>#Model.FacultyCompositionColumnHeader[2]</strong></td>
</tr>
<tr>
<td><span>M</span></td>
<td><span>F</span></td>
</tr>
}
else
{
<tr>
<td colspan="2"><strong></strong></td>
</tr>
<tr>
<td><span></span></td>
<td><span></span></td>
</tr>
}
</table>
</text>).Width(20);
columns.Template(#<text>
<table cellspacing="0" cellpadding="0">
<tr id="data">
<td>
<input type="text" class="FacultyCompositionTextbox" value="#item.FCYear4Male" #(Model.ReadOnlyFacultyCompositionNew[3]) #(item.DisableCalculatedRow) maxlength="4" onkeypress="return IsNumeric(event);" /></td>
<td>
<input class="FacultyCompositionTextbox" type="text" value="#item.FCYear4Female" #(Model.ReadOnlyFacultyCompositionNew[3]) #(item.DisableCalculatedRow) maxlength="4" onkeypress="return IsNumeric(event);" />
<input class="FacultyCompositionTextbox" type="hidden" value="#item.EthnicityPK" /></td>
</tr>
</table>
</text>)
.HeaderTemplate(
#<text>
<table cellspacing="0" cellpadding="0">
#if (Model.FacultyCompositionColumnHeader[3] != "")
{
<tr>
<td colspan="2"><strong>#Model.FacultyCompositionColumnHeader[3]</strong></td>
</tr>
<tr>
<td><span>M</span></td>
<td><span>F</span></td>
</tr>
}
else
{
<tr>
<td colspan="2"><strong></strong></td>
</tr>
<tr>
<td><span></span></td>
<td><span></span></td>
</tr>
}
</table>
</text>).Width(60);
})
.DataBinding(dataBinding => dataBinding.Ajax())
.ABAGridConfiguration(true)
.KeyboardNavigation(kbd => kbd.EditOnTab(false))
.Render();
}
</div>
</div>
</div>
Finally found the solution :)
Steps Invloved :
1. To find the associated key value with TAB key
2. Once Keydown event fires focus moves to next control
$('input.FacultyCompositionTextbox').keydown(function(event) {
if(event.which == 9) {
//alert('a');
$(this).next('input.FacultyCompositionTextbox').focus();
}
});
Regards,
Praveen Nelge
i am trying to traverse an html document:
<body class="style_0">
<div>
<div class="style_1">Pending Test List</div>
<table style=" width: 100%;" id="AUTOGENBOOKMARK_4365445353431356880">
<col>
<col>
<tbody>
<tr>
<td style="vertical-align: baseline;">
<div class="style_4">Pending Test List</div>
</td>
<td style="vertical-align: baseline;">
<div class="style_5">SOME AGENCY Laboratories, Inc.</div>
</td>
</tr>
</tbody>
</table>
<table class="style_6" style=" width: 4.531in;" id="AUTOGENBOOKMARK_5083738604442918131">
<col style=" width: 1in;">
<col class="style_7" style=" width: 0.75in;">
<col class="style_8" style=" width: 0.6in;">
<col style=" width: 0.75in;">
<col style=" width: 2.375in;">
<tbody>
<tr class="style_9" style=" height: 0.5in;">
<td style="vertical-align: middle;">
<div class="style_10">Report Range:</div>
</td>
<td style="vertical-align: middle;">
<div class="style_11">01/01/2012</div>
</td>
<td style="vertical-align: middle;">
<div class="style_12">through</div>
</td>
<td style="vertical-align: middle;">
<div class="style_13">01/31/2012</div>
</td>
<td style="vertical-align: middle;">
<div class="style_14">(by Date Entered)</div>
</td>
</tr>
</tbody>
</table>
<table class="style_15" style=" width: 100%;" id="AUTOGENBOOKMARK_7602283385844673591" iid="/526
(QuRs78576248:0)">
<col style=" width: 0.75in;">
<col style=" width: 1.25in;">
<col style=" width: 1in;">
<col style=" width: 1.5in;">
<col style=" width: 1.5in;">
<col style=" width: 1.5in;">
<col>
<thead>
<tr>
<td colspan="4" style="vertical-align: baseline;"></td>
<td style="vertical-align: baseline;"></td>
<td style="vertical-align: baseline;"></td>
<td style="vertical-align: baseline;"></td>
</tr>
<tr>
<td style="vertical-align: baseline;">
<div class="style_16">Entered</div>
</td>
<td style="vertical-align: baseline;">
<div class="style_16">Spec. ID</div>
</td>
<td style="vertical-align: baseline;">
<div class="style_16">Batch/Pos.</div>
</td>
<td style="vertical-align: baseline;">
<div class="style_16">Test</div>
</td>
<td style="vertical-align: baseline;">
<div class="style_16">Client ID</div>
</td>
<td style="vertical-align: baseline;">
<div class="style_16">Client Name</div>
</td>
<td style="vertical-align: baseline;">
<div class="style_16">Agency</div>
</td>
</tr>
</thead>
<tbody>
<tr>
<td class="style_17" style="vertical-align: baseline;">
<div class="style_18">1/30/12</div>
</td>
<td class="style_17" style="vertical-align: baseline;">
<div class="style_19">ZZ324sdf</div>
</td>
<td class="style_17" style="vertical-align: baseline;">
<div class="style_18">51446 / 75</div>
</td>
<td class="style_17" style="vertical-align: baseline;">
<div class="style_20">HOLD_DE</div>
</td>
<td class="style_17" style="vertical-align: baseline;">
<div class="style_20">234234</div>
</td>
<td class="style_17" style="vertical-align: baseline;">
<div class="style_20">smith, john</div>
</td>
<td class="style_17" style="vertical-align: baseline;">
<div class="style_20">PPPM-6P - SOME AGENCY</div>
</td>
</tr>
<tr>
<td class="style_17" style="vertical-align: baseline;">
<div class="style_18">1/31/12</div>
</td>
<td class="style_17" style="vertical-align: baseline;">
<div class="style_19">SFD3434</div>
</td>
<td class="style_17" style="vertical-align: baseline;">
<div class="style_18">51668 / 17</div>
</td>
<td class="style_17" style="vertical-align: baseline;">
<div class="style_20">HOLD_DE</div>
</td>
<td class="style_17" style="vertical-align: baseline;">
<div class="style_20">FOY, EL</div>
</td>
<td class="style_17" style="vertical-align: baseline;">
<div class="style_20">FOY, ALEX</div>
</td>
<td class="style_17" style="vertical-align: baseline;">
<div class="style_20">someagency & Associates LLC</div>
</td>
</tr>
<tr>
<td class="style_17" style="vertical-align: baseline;">
<div class="style_18">1/31/12</div>
</td>
<td class="style_17" style="vertical-align: baseline;">
<div class="style_19">SFD3434</div>
</td>
<td class="style_17" style="vertical-align: baseline;">
<div class="style_18">51668 / 25</div>
</td>
<td class="style_17" style="vertical-align: baseline;">
<div class="style_20">HOLD_DE</div>
</td>
<td class="style_17" style="vertical-align: baseline;">
<div class="style_20">JAMISON, PA</div>
</td>
<td class="style_17" style="vertical-align: baseline;">
<div class="style_20">JAMISON, ROY</div>
</td>
<td class="style_17" style="vertical-align: baseline;">
<div class="style_20">someagency & Associates LLC</div>
</td>
</tr>
<tr>
<td class="style_17" style="vertical-align: baseline;">
<div class="style_18">1/31/12</div>
</td>
<td class="style_17" style="vertical-align: baseline;">
<div class="style_19">SFD3434</div>
</td>
<td class="style_17" style="vertical-align: baseline;">
<div class="style_18">51669 / 34</div>
</td>
<td class="style_17" style="vertical-align: baseline;">
<div class="style_20">HOLD_DE</div>
</td>
<td class="style_17" style="vertical-align: baseline;">
<div class="style_20">NEWMAN, SO</div>
</td>
<td class="style_17" style="vertical-align: baseline;">
<div class="style_20">NEWMAN, ALEX</div>
</td>
<td class="style_17" style="vertical-align: baseline;">
<div class="style_20">someagency & Associates LLC</div>
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="2" style="vertical-align: baseline;">
<div class="style_21">Total Tests:</div>
</td>
<td style="vertical-align: baseline;">
<div class="style_22">4</div>
</td>
<td style="vertical-align: baseline;"></td>
<td style="vertical-align: baseline;"></td>
<td style="vertical-align: baseline;"></td>
<td style="vertical-align: baseline;"></td>
</tr>
</tfoot>
</table>
<table style=" width: 100%;" id="AUTOGENBOOKMARK_8507236727661888074">
<col>
<col>
<col>
<tbody>
<tr>
<td style="vertical-align: baseline;">
<div class="style_2">
<br>Feb 13, 2012 9:37 AM</div>
</td>
<td style="vertical-align: baseline;">
<div class="style_3">
<br>
<div style="text-align:center;">Page 1</div>
</div>
</td>
<td style="vertical-align: baseline;"></td>
</tr>
</tbody>
</table>
</div>
</body>
for this data:
so far i have this:
foreach (var row in htmlSnippet.DocumentNode.SelectNodes("//table[#class = 'style_15']/tbody/tr"))
{
foreach (var cell in row.SelectNodes("div[#class='*']"))
{
textBox1.Text = cell.InnerHtml.ToString();
}
}
however i am not returning anything!
this line is working:
//table[#class = 'style_15']/tbody/tr
but this does not return anthing:
("div[#class='*']"))
please let me know what i am doing wrong! i need help returning every piece of data as shown in the image (except for the field names)
The * is typically used for matching any element or attribute name, not any value. If you want to match all div elements having a class attribute with any value, just use #class.
foreach (var row in htmlSnippet.DocumentNode.SelectNodes("//table[#class = 'style_15']/tbody/tr/td"))
{
foreach (var cell in row.SelectNodes("div[#class]"))
{
textBox1.Text = cell.InnerHtml.ToString();
}
}
You probably want simply div[#class]—a div element that has a class attribute.
Oh, it's also worth noting that the HTML/XML sample you provided is not well-formed. I had to remove all the col elements, and close the br elements. Maybe, for C#, that's an issue... I know it is for XSL in general... not sure about XPath.
I don't have time to code up a C# example, but here's a simple XSL:
<xsl:template match="/">
<so>
<xsl:apply-templates select="//table[#class = 'style_15']/tbody/tr"/>
</so>
</xsl:template>
<xsl:template match="div[#class]">
<xsl:copy-of select="."/>
</xsl:template>
I get this output:
<so>
<div class="style_18">1/30/12</div>
<div class="style_19">ZZ324sdf</div>
<div class="style_18">51446 / 75</div>
<div class="style_20">HOLD_DE</div>
<div class="style_20">234234</div>
<div class="style_20">smith, john</div>
<div class="style_20">PPPM-6P - SOME AGENCY</div>
<div class="style_18">1/31/12</div>
<div class="style_19">SFD3434</div>
<div class="style_18">51668 / 17</div>
<div class="style_20">HOLD_DE</div>
<div class="style_20">FOY, EL</div>
<div class="style_20">FOY, ALEX</div>
<div class="style_20">someagency & Associates LLC</div>
<div class="style_18">1/31/12</div>
<div class="style_19">SFD3434</div>
<div class="style_18">51668 / 25</div>
<div class="style_20">HOLD_DE</div>
<div class="style_20">JAMISON, PA</div>
<div class="style_20">JAMISON, ROY</div>
<div class="style_20">someagency & Associates LLC</div>
<div class="style_18">1/31/12</div>
<div class="style_19">SFD3434</div>
<div class="style_18">51669 / 34</div>
<div class="style_20">HOLD_DE</div>
<div class="style_20">NEWMAN, SO</div>
<div class="style_20">NEWMAN, ALEX</div>
<div class="style_20">someagency & Associates LLC</div>
</so>
This is just an intermediate output to show that the XPath is working correctly.
Hope this helps.