HOw to get selection node h2 tag on http agility pack

<div id="content">
<div class="sense-block" id="1-1>
<h2>
<span class="hw">appear</span>
<span class="posgram">
<span class="pos" title="A word that describes an action, condition or experience.">verb</span>
</span>
<span class="guideword" title="Guide word: helps you find the right meaning when a word has more than one meaning">
(BE PRESENT)
</span>
</h2>
<div class="sense-body">
<span class="def-block">
<span class"def-body">
<span class"examp"></span>
<span class"examp"></span>
</span>
</span>
<span class="def-block>
<span class="def-body">
<span class"examp"></span>
<span class"examp"></span>
</span>
</span>
</div>
</div>
<div class="sense-block" id="1-2>
<h2></h2>
<div class="sense-body">
<span class="def-block"></span>
<span class="def-block></span>
</div>
</div>
</div>
var newsListNodehtml = htmlDoc.GetElementbyId("1-1");
if(newsListNodehtml!=null)
var senseblock = newsListNodehtml.Descendants("span").Where(x => x.GetAttributeValue("class", "") == "def-block");
if(senseblock!=null)
foreach(var node in senseblock)
Dictionaries = new Models.EnglishDictionary();
var title = node.Descendants("span").FirstOrDefault(x => x.GetAttributeValue("class", "") == "def");
var examp = node.Descendants("span").FirstOrDefault(x => x.GetAttributeValue("class", "") == "def-body");
//Dictionaries.Symbol = "/Photos/glasses-50.png";
if (title != null)
Dictionaries.Description = title.InnerText.Trim();
if (examp != null)
Dictionaries.Examp = examp.InnerText.Trim();
var hw = node.Descendants("span").FirstOrDefault(x => x.GetAttributeValue("class", "") == "hw");
var prsgram = node.Descendants("span").FirstOrDefault(x => x.GetAttributeValue("class", "") == "posgram");
var word = node.Descendants("span").FirstOrDefault(x => x.GetAttributeValue("class", "") == "guideword");
if (hw != null)
Dictionaries.Word = hw.InnerText.Trim();
if (word != null)
Dictionaries.GuideWord = word.InnerText.Trim();
if (prsgram != null)
Dictionaries.Grammar = prsgram.InnerText.Trim();
//Dictionaries.Phrase=pharsel.InnerText;
arrays.Add(Dictionaries);
<div id="x_x_1-1>">
var senseblock = newsListNodehtml.Descendants("span").Where(x => x.GetAttributeValue("class", "") == "def-block");
So, senseblock will not be have <h2> tag. Of couse that results is null to (foreach will be play two time and getting def-block two times"
 But If I changed It(senseblock ) to 
          var newsListNodehtml = htmlDoc.GetElementbyId("content"); // content is contain all tag
            if(newsListNodehtml!=null)
                var senseblock = newsListNodehtml.Descendants("span").Where(x => x.GetAttributeValue("class", "") == "sense-block");
Then  foreach that just play the def-block once time.
Note: I'm still want get all of h2 tag and def-block(two time because of having 2 div def-block tag)in id 1-1. How???

Thanks, I figured out this my ways to solve it.
I want ask you: How to return Lis<> (async). 
Ex:
public async void loaddata(string id)
var httpClient = new HttpClient();
var srtHtml = await httpClient.GetStringAsync("http://dictionary.cambridge.org/dictionary/british/appeal");
var htmlDoc = new HtmlDocument();
htmlDoc.LoadHtml(srtHtml);
List<Models.EnglishDictionary> arrays = new List<Models.EnglishDictionary>();
var newsListNodehtml = htmlDoc.GetElementbyId("entryContent");
if (newsListNodehtml != null)
var senseblock = newsListNodehtml.Descendants("div").Where(x => x.GetAttributeValue("id", "") == id);
if (senseblock != null)
foreach (var node in senseblock)
Dictionaries = new Models.EnglishDictionary();
var def = node.Descendants("span").FirstOrDefault(x => x.GetAttributeValue("class", "") == "def");
var examp = node.Descendants("span").FirstOrDefault(x => x.GetAttributeValue("class", "") == "def-body");
//Dictionaries.Symbol = "/Photos/glasses-50.png";
if (def != null)
Dictionaries.Description = def.InnerText.Trim();
if (examp != null)
Dictionaries.Examp = examp.InnerText.Trim();
var hw = node.Descendants("span").FirstOrDefault(x => x.GetAttributeValue("class", "") == "hw");
var prsgram = node.Descendants("span").FirstOrDefault(x => x.GetAttributeValue("class", "") == "posgram");
var word = node.Descendants("span").FirstOrDefault(x => x.GetAttributeValue("class", "") == "guideword");
if (hw != null)
Dictionaries.Word = hw.InnerText.Trim();
if (word != null)
Dictionaries.GuideWord = word.InnerText.Trim();
if (prsgram != null)
Dictionaries.Grammar = prsgram.InnerText.Trim();
arrays.Add(Dictionaries);
else
// error = "No data";
Listview.itemsource=arrays;
I want on ousite it will called back into "itemsource" of lisview.
Ex:Listview.itemsource=loaddata("1-1");
How???

Similar Messages

  • How to get selected  row index  of a Table ?

    hi gurus,I'm new  to Webdynpro for abap
    I'm displaying    just Flight details in a Table  so
    how to get selected  row index  of a  Table  and need  to be display in Message manager.

    Hi,
    For getting the row index use the following code.
    DATA lo_nd_node TYPE REF TO if_wd_context_node.
      DATA lo_el_node TYPE REF TO if_wd_context_element.
      DATA index TYPE i.
    * navigate from <CONTEXT> to <NODE> via lead selection
      lo_nd_node = wd_context->get_child_node( name = wd_this->wdctx_node ).
      lo_el_node = lo_nd_node->get_lead_selection(  ).
      index = lo_el_node->get_index( ).
    node is the name of the node which is binded to the table.
    For printing the message u can use code wizard.
    Press ctrl-F7. Now Select generate message.
    IN this select the method  REPORT_SUCCESS
    In the code now u can give index to Message text Exporting parameter. Comment receiving parameter.
    Write the whole code in onLeadSelect of the table.
    Regards,
    Pankaj Aggarwal

  • How do that to get ul tag on html agility pack???

    How to get of all  ul tags in id 1-1.
    Here my code:
    string id="1-1";
    public async void ExampLoad(string id)
    var httpClient = new HttpClient();
    string srtHtml = await httpClient.GetStringAsync("http://dictionary.cambridge.org/dictionary/british/appeal");
    var htmlDoc = new HtmlDocument();
    htmlDoc.LoadHtml(srtHtml);
    List<Models.EnglishDictionary> arrays = new List<Models.EnglishDictionary>();
    var NewListNodeHtml = htmlDoc.GetElementbyId("entryContent");
    if(NewListNodeHtml!=null)
    var SenseBlock = NewListNodeHtml.Descendants("div").Where(x => x.GetAttributeValue("id", "") == id);
    if(SenseBlock!=null)
    foreach(var node in SenseBlock)
    Dictionaries = new Models.EnglishDictionary();
    var ul = node.Descendants("div").FirstOrDefault(x => x.GetAttributeValue("class", "") == "extraexamps");
    if(ul!=null)
    Dictionaries.Examp = ul.InnerText.Trim();
    arrays.Add(Dictionaries);
    lstExample1_1.ItemsSource = arrays;

    Hi Greg,
    In general I would recommend you to ask question at
    http://htmlagilitypack.codeplex.com/ for a better support on third party library, thanks for your understanding.
    Additionally I found some discussion:
    http://stackoverflow.com/questions/28199504/retrieve-ul-li-tags-with-using-html-agility-pack, the answer contains a workable code for how to find tag by html agility pack.
    --James
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to get selected value from selectOneRadio ???

    Hi...i want to how to get selected value from selectOneRadio and use it in another page and in backing bean.
    Note i have about 10 selectOneRadio group in one page i want to know value of each one of them.
    Plzzzzzzzz i need help

    You have a datatable in which each row is a question, correct?
    Also in each row you have 5 possible answers that are in a radio, correct?
    So,
    You need to put in your datatable model, a question, and a list of answers (5 in yor case) and the selected one.
    So you will have a get to the question, an SelectItem[] list to populate the radios and another get/set to the selected question.
    ex:
    <h:selectOneRadio value="#{notas.selectedString}" id="rb">
    <f:selectItem itemValue="#{notas.valuesList}"/>
    </h:selectOneRadio>
    Search the web for examples like yours.

  • How to get selected value from OADefaultListBean.

    Hi All,
    How to get selected value from OADefaultListBean ?
    Thanks,

    Hi,
    To identify the user's selection(s) when the page is submitted, you would add the following logic to your processFormRequest() method:
    OADefaultListBean list =
    (OADefaultListBean)webBean.findChildRecursive("positionsList");
    String name = list.getName();
    String[] selectedValues = pageContext.getParameterValues(name);
    To retrieve all the values in the list box, call list.getOptionsData().
    --Prasanna                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to get each node in tree?

    how to get each node in tree?
    Message was edited by:
    NikisinProblem

    how to get each node in tree?
    Since (as far as I know) treeNode is an interface, the real question to me is how are you implementing your treeNodes? Are you overriding the toString() method?

  • How to get selected row keys from RichSelectManyCheckbox

    Adf Table has getSelectedRowKeys but SelectManyChekcbox does not has anything similar. Can you tell me how to get selected row keys programmatically for RichSelectManyCheckbox?

    Hi User,
    selectManyCheckbox component's value property holds the selected items values. Bind this property to some bean variable(of type list) so that you can get the selected values by accessing the bean property.
    Sireesha

  • How to get the node id of the content shown from campaign

    Hi
    Can any one please tell how to get the node id of the content shown by the campaign
    in jsp
    Thanks

    One option is to define a custom ad renderer, which is registered with the proper mime-type.
    The campaign would run your renderer if the campaign retrieved a node with a binary of the proper registered mime-type.
    This allows you to insert yourself into the call chain for the node rendering. You can access the nodeID at that point (and do the typical rendering-- providing a URL for the ShowPropertyServlet)
    -Steve

  • How to get the node value of payload

    Hi
    The null is returned when I use the following code to get the User_ID element in the payload, but there are values in the User_ID element of the payload
    Task task_test = wfSvcClient.getTaskQueryService().getTaskDetailsById(wfCtx, taskId);
    System.out.println("the payload value is " + task_test.getPayloadAsElement().getElementsByTagName("User_ID").item(0).getNodeValue());
    How to get the node value of payload ? any suggestion?
    Thanks
    Jayson

    Hi Jayson,
    Try:
    System.out.println("the payload value is " + task_test.getPayloadAsElement().getElementsByTagName("User_ID").item(0).getFirstChild().getNodeValue());
    So add the getFirstChild() call in between.
    If this works, maybe consider using JAXB to marshall the payload details to POJO's. This will make reading the payload details much easier.
    Regards, Ronald

  • How to get 2 xml(Sibling tag) content same time and merge them

    how to get 2 xml(Sibling tag) content same time and merge them and search the result value in indesign file with page number  
    Like
    <Record>
    <A>this is a text</A>
    <B>a-123</B>
    </Records>
    First we need  tag A and B value as  :
    this is a text - a-123 and then get  this text page number form the indesign doc
    plz help

    hi
    var root = app.activeDocument.xmlElements[0];
    var aTag = root.evaluateXPathExpression("//Record/INAAMF");
    var bTag = root.evaluateXPathExpression("//Record/IAFKF");
    here I got  aTag  and bTag  = empty
    may be the reason is as I forgot to menion the proper XML path as
    <Records>
    <Record>
    <A>this is a text</A>
    <B>a-123</B>
    </Record>
    <Record>
    <A>Second text</A>
    <B>a-132</B>
    </Record>
    <Record>
    <A>Thied text</A>
    <B></B>
    </Record>
    <Records>

  • How to get a node selection in a table using Arraylist

    Hi All,
      Can someone help me with the code to get the node selected value from a table and then set that values to input fields?
    Early response would be much appreciated.
    Thanks
    Uday

    Dear Uday,
    Please user the isMultiSelected inside the for loop and iterate through all the rows selected to set in the arraylist.
    Refer to this might help: delete records from table
    if(wdContext.node<Node Name>().size()>0)
                // Iterate through the context Node
                for(int i=0;i<wdContext.node<Node Name>().size();i++)
           if(wdContext.node<Node Name>().isMultiSelected(i))  {
                      // Set the ArrayList here for the Lead Selected elements of the Table multiple selected rows
                            }else {
                                   // Set the ArrayList here for the Lead Selected elements of the Table single selected rows
    Best Regards
    Arun Jaiswal
    Edited by: Arun Jaiswal on Dec 10, 2011 2:04 PM

  • How to get selected items from a tree in backing bean without adfbc

    Hi ADF Experts,
    Below is my code for af:tree. My question is how can I get selected Items from the selectionListener (without adf bc) this uses formation of tree from backing bean.
    Using Jdev 11.1.1.7.0
    <af:tree var="node" value="#{pageFlowScope.MerchandizeBean.model}"
                      binding="#{pageFlowScope.MerchandizeBean.treeModel}"     id="tree" immediate="true" autoHeightRows="0"
                           styleClass="AFStretchWidth" rowSelection="multiple"
                           selectionListener="#{pageFlowScope.MerchandizeBean.treeNodeSelection}">
                    <f:facet name="nodeStamp">
                      <af:commandLink text="#{node.classDescription}"
                           actionListener="#{pageFlowScope.MerchandizeBean.createListManyItemForMerchandise}"           id="displayTable" partialSubmit="true">
                      </af:commandLink>
                    </f:facet>
                  </af:tree>
        public void treeNodeSelection(SelectionEvent selectionEvent) {
            // Add event code here...
            RichTree tree = (RichTree)selectionEvent.getSource();
                    TreeModel model = (TreeModel)tree.getValue();
                    //get selected value
    Thanks
    Roy

    Hi,
    in a multi select case, try
    RowKeySet rks = tree.getSelectedRowKeys();
    Iterator iter = rks.iterator();
    while(iterator.hasNext()){
    Object aKey = iterator.next();
    tree. setRowKey(aKey);
    Object rowData ? tree.getRowData();
      .... do something with the data here ...
    Frank

  • How to get the Node Value from XmlValue result?

    Hi ,
    I am not able to get the Node Value from the result. In my XQuery im selecting till a Node, if i change my query as
    collection('PhoneBook')/phone_book/contact_person/address/string()", qc);
    im getting the node value, but here the problem is its not a Node so i cannot get the Node name.
    So how can i get the Node Name and Node value together?
    any help please ????
    XML :
    <?xml version="1.0" encoding="UTF-8"?>
    <phone_book>
    <contact_person>
    <name>
    <first_name>Michael</first_name>
    <second_name>Harrison</second_name>
    </name>
    <address city="yyyyy" pincode="600017" state="xxxxx">
    176 Ganesan street, Janakinagar, alwarthirunagar
    </address>
    </contact_person>
    <phone_number type="mobile">9881952233</phone_number>
    <phone_number type="home">044-24861311</phone_number>
    <phone_number type="office">080-12651174</phone_number>
    </phone_book>
    Code:
    XmlQueryContext qc = manager.createQueryContext();
    XmlResults rs = manager.query
    ("collection('PhoneBook')/phone_book/contact_person/address", qc);
    while(rs.hasNext()){
    XmlValue val = rs.next();
    System.out.println(val.getNodeName() + " = [ " + val.getNodeValue() + " ] ");
    Output
    address = [  ]

    You are right, this seemed un-intuitive to me too, but I finally understood how it's done.
    The "value" of a node is actually the total amount of text that is not contained in any of the node's child nodes (if any). So a node with child nodes can still have text value.
    To get the 'value' of an element node, you must therefore concatenate the values of all children of type "XmlValue::TEXT_NODE", of that node. Try it.
    In your example, the <address> node has no child elements, my guess is that BDB XML stores the address string "176 Ganesan street, Janakinagar, alwarthirunagar" inside a child node of <address> node (of type XmlValue::TEXT_NODE) because you wrote the string on a separate line.

  • How to get correct node in JTree with DISCONTIGUOUS_TREE_SELECTION mode?

    The following code creats a JTree with DISCONTIGUOUS_TREE_SELECTION mode. When select a single node, the node's name is printed correctly as expected. However, in Window environment, after select one node, if holding the ctrl key and select a different node, the program still prints out the name of the first selected node although both nodes are highlighted. Can some one tell me how to get the name of the second (i.e. the last) selected node printed?
    Thank you very much!
    import javax.swing.*;
    import javax.swing.tree.*;
    import javax.swing.event.*;
    import java.io.*;
    public class TestTree extends JFrame {
    JTree tree;
    public TestTree() {
    super();
    setBounds(0,0,500,500);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    tree = new JTree();
    getContentPane().add(tree);
    TreeSelectionModel model = new DefaultTreeSelectionModel();
    model.setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    tree.setSelectionModel(model);
    tree.addTreeSelectionListener(new TreeSelectionListener() {
    public void valueChanged(TreeSelectionEvent e) {
    Object obj = tree.getLastSelectedPathComponent();
    System.out.println(obj.toString());
    public static void main(String [] args) {
    TestTree test = new TestTree();
    test.show();

    Hi!
    Try this, maybe it's what you want?
    /Smedman
    public void valueChanged(TreeSelectionEvent e)
        TreePath[] paths = tree.getSelectionPaths();
        for (int i = 0; i < paths.length; i++)
            System.out.println(paths.getLastPathComponent());

  • JTree get selected node/object values

    I wan to get all the selected nodes/objects values that I added to the JTree. How can I do this?
    Thanks.

    TreePath[] paths = tree.getSelectedPath();
    for(int i = 0; i < paths.length; i++){
    TreeNode node = (TreeNode)paths.getLastPathComponent();
    Object mySelectedObject = node.getUserObject();
    }Some minor Errors
    We have to use array paths[i] instead of paths
    The correct code as used by me is
            javax.swing.tree.TreePath[] paths = jTree1.getSelectionModel().getSelectionPaths();
            for(int i = 0; i < paths.length; i++){
                javax.swing.tree.TreeNode node = (javax.swing.tree.TreeNode)paths.getLastPathComponent();
    System.out.println(((javax.swing.tree.DefaultMutableTreeNode)node).getUserObject());
    CSJakharia

Maybe you are looking for

  • Unable to access certain ports over Site to Site VPN

    We have a client that has a Cisco 1801W Firewall that is setup as a site to site VPN terminating to a Cisco ASA 5505. The tunnel is up and established, I can ping from both sides of the tunnel. The problem is the clients behind the Cisco ASA (192.168

  • Installing a windows 7 (64 bit) printer driver to existing windows xp network

    Dear-Users......... i have connected 5 computers through a switch and ( hp laserjet 2014) printer is directly connected to one of them and shared on the network.  3 computers running on windows xp and one i added last time it was windows 7 (32 bit) i

  • Some questions on OAF?

    hello friends, i have few question on OAF? i checked this in forum, but i could not find anyhting. please give me suitable answers for them.thanks for your help. 1)what is difference between row count and fetched row count? 2)What is difference betwe

  • ADFS 2.0 service does not automatically start after reboot

    Hello, We have two ADFS 2.0 servers in a farm.  Any time these servers reboot, the ADFS service does not automatically start, even though the service is set to auto start.  If I manually start the service it starts within 10 seconds. The error in the

  • Working with DataProvider - tutorial

    I created a page following the instructions in the 'Working with Data Provider' tutorial - for page2. i.e., I created a page with some fields bound to a data provider (at page level) whose rowset is in session bean. The page has commit and reset butt