Document doc = XMLParser.parse(xml);
Element vcardElement = XMLHelper.findSubTag(doc.getDocumentElement(), "vCard");
if(vcardElement == null)
return false;
NodeList childs = vcardElement.getChildNodes();
for(int index = 0;index<childs.getLength();index++)
{
Node child = childs.item(index);
String tagName = child.getNodeName().toUpperCase();
String value = XMLHelper.getTagContent((Element) child);
if(tagName.equals("VERSION"))
version = value.trim();
else if(tagName.equals("FN"))
fullName = value.trim();
else if(tagName.equals("NICKNAME"))
nickName = value.trim();
else if(tagName.equals("PHOTO"))
photo = XMLHelper.subTagText((Element) child, "BINVAL");
else if(tagName.equals("BDAY"))
bday = value.trim();
else if(tagName.equals("ADR"))
{
Address a = new Address();
a.home = XMLHelper.hasSubTag((Element) child, "HOME");
a.work = XMLHelper.hasSubTag((Element) child, "WORK");
a.postal = XMLHelper.hasSubTag((Element) child, "POSTAL");
a.parcel = XMLHelper.hasSubTag((Element) child, "PARCEL");
a.dom = XMLHelper.hasSubTag((Element) child, "DOM");
a.intl = XMLHelper.hasSubTag((Element) child, "INTL");
a.pref = XMLHelper.hasSubTag((Element) child,"PREF");
a.pobox = XMLHelper.subTagText((Element) child, "POBOX");
a.extaddr = XMLHelper.subTagText((Element) child, "EXTADR");
a.street = XMLHelper.subTagText((Element) child, "STREET");
a.locality = XMLHelper.subTagText((Element) child, "LOCALITY");
a.region = XMLHelper.subTagText((Element) child, "REGION");
a.pcode = XMLHelper.subTagText((Element) child, "PCODE");
a.country = XMLHelper.subTagText((Element) child, "CTRY");
if(a.country.isEmpty())
{
if(XMLHelper.hasSubTag((Element) child, "COUNTRY"))
a.country = XMLHelper.subTagText((Element) child, "COUNTRY");
}
if(a.extaddr.isEmpty())
{
if(XMLHelper.hasSubTag((Element) child, "EXTADD"))
a.extaddr = XMLHelper.subTagText((Element) child, "EXTADD");
}
addressList.add(a);
}
else if(tagName.equals("LABEL"))
{
Label l = new Label();
l.home = XMLHelper.hasSubTag((Element) child, "HOME");
l.work = XMLHelper.hasSubTag((Element) child, "WORK");
l.postal = XMLHelper.hasSubTag((Element) child, "POSTAL");
l.parcel = XMLHelper.hasSubTag((Element) child, "PARCEL");
l.dom = XMLHelper.hasSubTag((Element) child, "DOM");
l.intl = XMLHelper.hasSubTag((Element) child, "INTL");
l.pref = XMLHelper.hasSubTag((Element) child, "PREF");
NodeList lines = child.getChildNodes();
for(int i = 0;i<lines.getLength();i++)
{
Element line = (Element) lines.item(i);
if(line.getTagName().toUpperCase().equals("LINE"))
{
if(!XMLHelper.getTagContent(line).isEmpty())
l.lines.add(XMLHelper.getTagContent(line));
}
}
labelList.add(l);
}
else if(tagName.equals("TEL"))
{
Phone p = new Phone();
p.home = XMLHelper.hasSubTag((Element) child, "HOME");
p.work = XMLHelper.hasSubTag((Element) child, "WORK");
p.voice = XMLHelper.hasSubTag((Element) child, "VOICE");
p.fax = XMLHelper.hasSubTag((Element) child, "FAX");
p.pager = XMLHelper.hasSubTag((Element) child, "PAGER");
p.msg = XMLHelper.hasSubTag((Element) child, "MSG");
p.cell = XMLHelper.hasSubTag((Element) child, "CELL");
p.video = XMLHelper.hasSubTag((Element) child, "VIDEO");
p.bbs = XMLHelper.hasSubTag((Element) child, "BBS");
p.modem = XMLHelper.hasSubTag((Element) child, "MODEM");
p.isdn = XMLHelper.hasSubTag((Element) child, "ISDN");
p.pcs = XMLHelper.hasSubTag((Element) child, "PCS");
p.pref = XMLHelper.hasSubTag((Element) child, "PREF");
p.number = XMLHelper.subTagText((Element) child, "NUMBER");
if(p.number.isEmpty())
{
if(XMLHelper.hasSubTag((Element) child, "VOICE"))
p.number = XMLHelper.subTagText((Element) child, "VOICE");
}
phoneList.add(p);
}
else if(tagName.equals("EMAIL"))
{
Email m = new Email();
m.home = XMLHelper.hasSubTag((Element) child, "HOME");
m.work = XMLHelper.hasSubTag((Element) child, "WORK");
m.internet = XMLHelper.hasSubTag((Element) child, "INTERNET");
m.x400 = XMLHelper.hasSubTag((Element) child, "X400");
m.userid = XMLHelper.subTagText((Element) child, "USERID");
if (m.userid.isEmpty())
{
if(!XMLHelper.getTagContent((Element)child).isEmpty())
{
m.userid = XMLHelper.getTagContent((Element)child);
}
}
emailList.add(m);
}
else if(tagName.equals("JABBERID"))
jid = value.trim();
else if(tagName.equals("MAILER"))
mailer = value.trim();
else if(tagName.equals("TZ"))
timezone = value.trim();
else if(tagName.equals("GEO"))
{
geo.lat = XMLHelper.subTagText((Element) child, "LAT");
geo.lon = XMLHelper.subTagText((Element) child, "LON");
}
else if(tagName.equals("TITLE"))
title = value.trim();
else if(tagName.equals("ROLE"))
role = value.trim();
else if(tagName.equals("LOGO"))
{
logo = XMLHelper.subTagText((Element)child, "BINVAL");
logoURI = XMLHelper.subTagText((Element)child, "EXTVAL");
}
else if(tagName.equals("AGENT"))
{
}
else if(tagName.equals("ORG"))
{
org.name = XMLHelper.subTagText((Element)child, "ORGNAME");
NodeList units = child.getChildNodes();
for(int iunit = 0;iunit<units.getLength();iunit++)
{
Element unit = (Element) units.item(iunit);
if(!XMLHelper.getTagContent(unit).isEmpty())
org.unit.add(XMLHelper.getTagContent(unit));
}
}
else if(tagName.equals("NOTE"))