Menu

Nested List

apple
2011-06-14
2012-09-04
  • apple

    apple - 2011-06-14

    I did the following:

    <var-def name="myList">
            <while condition="true" index="i" maxloops="5">
                <var-def name="object">
                            <var-def name="element1">
                                  <text>element1</text>
                           </var-def>
                            <var-def name="element2">
                                  <text>element2</text>
                           </var-def>
               </var-def>                               
    </var-def>
    

    In my code, I get my list as follow:

    Variable myListVariable= (Variable) scraper.getContext().getVar("myList"); 
    List<Variable> l = myListVariable.toList();
    int size = l.size();
    

    The size is 10.

    What I like to have is "myList" containing a list of "object", and each
    "object" has a list of "element".

    Can this be a feature to have?

     
  • Alex Wajda

    Alex Wajda - 2011-07-01

    Please the post #3 in this topic - https://sourceforge.net/projects/web-
    harvest/forums/forum/591299/topic/4571683

    As an alternative you can have a list of JSON or you can create objects
    explicitly using <script> tag. But I doubt if it would work in the version 2.0
    beta1, but you can try. In 2.1 it works much better, but this release is still
    under development.

     

Log in to post a comment.