views:

95

answers:

1

when adding annotation programatically ,refer to http://code.google.com/intl/en/apis/customsearch/docs/api.html#create_annos , can i assign "id" to each annotation so later on, when i need to delete it i can just delete by the id instead of required to retrieve all the annotation and delete it?

+1  A: 

The page you linked to describes how this works:

The XML for removing annotations is slightly different. Instead of using the full annotation format with URL and label names, you just need to use the annotations ID or href id. Custom Search tags each annotation with an href id. To get this ID, retrieve all the annotations and extract the href id of the annotations you want to delete.

The following is a code snippet that removes annotations.

  <Remove>
     <Annotations>
       <Annotation href="Cg93d3cuZ29vZ2xlLmNvbS8Qrsq3gv456gRI" />
       <Annotation href="Cg93d3cuZ29vZ2xlLmNvbS8Qzsq3gvWd23" />
     </Annotations>
  </Remove>

In other words, no, you cannot assign your own ID to an annotation; you have to retrieve the list of existing annotations to find the ID of the element(s) you want to remove.

Nick Johnson