I have Repo items in Web application that represent HTML tags that may or may not have children. I'll show examples below. I want to determine through script what the DOM tree is and manipulate it accordingly.
Here I want to see what sits beneath <>TD.
<>TBody
<>TR
<>TD
<>TBody
<>TR
<>TD
<>Big '20'
<>Br
<>Div ' Sold Out '
<>B '8:00 PM'
<>Br
<>TBody
<>TR
<>TD
<>Big '21'
<>Br
<>Div
<>B '8:00 PM'
<>A 'Tickets'
<>Br
How to find child TAGs in DOM tree?
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: How to find child TAGs in DOM tree?
Hi Zee357,
I’m unfortunately not exactly sure what you want to do, but you can iterate through the children of a Repository Item by using the following code snippet
Regards,
Markus (S)
I’m unfortunately not exactly sure what you want to do, but you can iterate through the children of a Repository Item by using the following code snippet
TdTag item = repo.WebPage.Table.FindSingle(".//td[@innertext='Big 20']"); foreach(Unknown child in item.Children) Report.Info(child.ToString());If you would like to get all descendants you can use this snippet
TdTag item = repo.WebPage.Table.FindSingle(".//td[@innertext='Big 20']"); IList<Unknown> descendants = item.FindDescendants<Unknown>(); foreach(Unknown child in descendants) Report.Info(child.ToString());Please let me know if that helps solving your problem.
Regards,
Markus (S)