[Cosmo-dev] VCard Parsing in Cosmo

Vinubalaji Gopal vinu at osafoundation.org
Tue Jul 18 13:44:55 PDT 2006

On Tue, 2006-07-18 at 13:20 -0700, Brian Moseley wrote:

> are you doing something more than this?
> Node adbkNode = null;
> DomParser.parse(in, adbkNode);
> AddressBook adbk = new Addressbook(adbkNode);
> VCard vcard = (VCard) adbk.getVCards().n

>From the MainDom.java file of the sampe application:
DomParser parser = new DomParser();
Document document = new DocumentImpl();
parser.parse(new FileInputStream(args[i]), document);

This creates the DOM in the document variable. I do the parsing by doing
xpath queries on this document variable. 

> why would it be inefficient and hard to implement?
VCard vcard = (VCard) adbk.getVCards();

for (Iterator vcards = addressBook.getVCards(); vcards.hasNext(); ) {
	VCard vcard = (VCard) vcards.next();
        for (Iterator types = vcard.getTypes(); types.hasNext(); )
      Type type = (Type) types.next();
                    System.out.println("Got type:" + type.getName());

//Type is the base class for all types like FN, N, etc..there is no
method like type.get() to get the value...so I am trying to see if I
could create a super type and get all the values or else I need to
create a lot of objects.


//Inefficient because it ultimately works on the dom structure and I
suspect that it will do more Xpath queries than I would do. Also if
there is no standard way of accessing the object I may need to create a
lot of objects for each type.

More information about the cosmo-dev mailing list