Welcome to openkapow Sign in | Join
in Search
.

How to compare a tag to an attribute?

Last post 10-26-2007, 10:17 AM by lollipop7081. 6 replies.
Sort Posts: Previous Next
  •  02-23-2007, 12:46 AM 8263

    How to compare a tag to an attribute?

    I hope someone can help me, because I am stuck.

    I am looping through some tags which I can find easily. At each step, I want to compare the text delimited by this tag to another text I stored in the RSSItem.rights attribute.

    If the first string (the tag text) is contained in the second one (the RSSItem.rights), then do action_X and continue looping, else just continue looping.

    I cannot get to do this, so 2 questions about how to do this:

    - How can I compare the tag text to the value stored in an RSSItem ? I tried Test tag, but I can only specify a pattern, and RSSItem.rights does not seem to be recognized when I use it in the pattern. What am I doing wrong? I cannot see any menu relating to attributes in the pattern window!

    - Action says: "Stop if Pattern matches found tag" or "Continue if Pattern matches found tag". I do not want to do either, I just want to do "Do next action only if pattern matches last input". In other words, is there something like the classical "if ... then ... else ... endif" in RoboMaker?

     Any help appreciated, thanks.

  •  02-23-2007, 3:52 AM 8270 in reply to 8263

    Re: How to compare a tag to an attribute?

    Hi,

    1: Extract the content you want to test into two object attributes. One part you already have (RSSItem.rights) and the second part you could extract into ScratchPad.shortText1 (requires you to add this object to the robot). With this done you can use the "Test Attributes" which allow you to set up a series of tests. Most importantly it allow you to test if a certain content is "contained in" or if it "contains" a second content. The result will always be either true or false.

    2: While not apparent, you can setup a "if.. then.. elseif.." functionality. In a robot, each step can be viewed as an "if" statement. If the step completes correctly and result in an output then the following step will be executed. If the step fails, then an error is thrown (e.g a link was not found as specified in the Tag Finder). You can use error handling to activate the "elseif" part. First you select that any error in a given step should be "Send Backwards". In the preceding step you now change the branching mode to "Until successful Branch" (the link between the steps become dotted). Finally you add a new branch and setup you alternative action.

    NOTE: When using a condition, the step can not fail as it will always evaluate to true or false. But you can select to throw an error when the step evaluates to false/stop (see the pane "Error Generation" under the Action configuration)

    I'll be uploading a robot showing this shortly. I'll keep you posted.


    The question is not:
    "Is it possible for a robot to ..." but rather:
    "How do I setup a robot to ..."
  •  02-25-2007, 2:56 AM 8304 in reply to 8270

    Re: How to compare a tag to an attribute?

    1. How do you add and attribute object to the robot? I could find "create global variable" or "assigne attribute" but nothing like "create attribute". I have no clue how to add ScratchPad.shortText1.

    2. I will look into this when you post an example.
    An other simple question: how to go out of a loop if a condition is met? I mean the equivalent of "loop tags; do_actions; until (condition)"  

  •  02-25-2007, 3:39 PM 8311 in reply to 8304

    Re: How to compare a tag to an attribute?

    OK, after playing around with Openkapow menus and buttons, I finally found it. In order to have access to the Scratchpad, you need to add it via the bottom right pane "Output objects", click on Add/remove" and press the "+" sign: there, you can add a ScratchPad in addition to an RSSItem object.
    It would be convenient if the help file coud return something when asked about "ScratchPad". But as this is still a beta, we should not expect too much of the help file, right?

    I am still not sure about my 2nd questions (how to escape a loop if a condition is met)?

  •  02-26-2007, 4:28 PM 8357 in reply to 8311

    Re: How to compare a tag to an attribute?

    My 2nd question is still open, but I will make a fresh thread for it -> please consider this thread closed.

  •  08-07-2007, 10:48 AM 12495 in reply to 8263

    Re: How to compare a tag to an attribute?

    First of all, excuse me for my bad english. I'm spanish.

    Maybe I can help you with question 2. I think you try to find a tag but sometimes the tag is not found. I solved that using another branch.

    In the down Test Tag I found "Actualmente no hay cursos" [There are no courses], Action= Continue if Pattern Matches Found Tag, in Error Handling, Own errors = Ignore and Skip Branch. With this Test if tag is not found, or not matches last input (in yout case), then continue with Do Nothing Tag, and the previous Loop continues with another iteration.

    In the upper Test Tag I do the same thing using the ".*Los Cursos programados para este centro son.*" Match Against, and continuing the branch with the main job.

    I can't post the snapshots in the forum..

    Best regards

    Miguel 

  •  10-26-2007, 10:17 AM 14355 in reply to 8311

    Re: How to compare a tag to an attribute?

    Not sure of the real content of your 2nd question but the tutorial titled Creating an RSS robot that pages through Digg discusses stopping a loop if a pattern matches the found tag in the 2nd to the last paragraph before the Summary.

    Hope this helps! 

View as RSS news feed in XML
.
Copyright 2006, 2007 KapowTech.com All Rights Reserved Company | Contact | Terms | Privacy