I am trying to parse the vCard info from a wildfire plugin I’‘m working on. I’‘m trying to get a hold of the business and home phone numbers that a user supplies in their profile. At first I thought I could use the VCardManager.getVCardProperty() method but that didn’‘t help because there are multiple elements in the vCard XML. My approach right now is to call VCardManager.getVCard() and parse the xml myself to get the number elements’’ values. However that is not working. Below is some code I did and the output.
— CODE —
// Get the phone number of the jive user from their VCard
VCardManager vcard = VCardManager.getInstance();
String user = ((Presence)packet).getFrom().getNode();
Log.info("VCard: " + vcard.getVCard(user).asXML());
// Extract the business and home phone numbers if present. From the vCard schema used by
// wildfire, the business phone number is the 2nd number and the home phone is the 6th
java.util.List numbers = vcard.getVCard(user).selectNodes("//TEL/NUMBER");
Log.info(“Found (” + numbers.size() + “) numbers”);
if( numbers.size() == 0)
Log.info(“No numbers were extracted from the vCard”);
– END CODE -
Now, when I run that code I get the following output.
— OUTPUT —
2006.09.28 14:30:49 VCard:
2006.09.28 14:30:49 Found (0) numbers
2006.09.28 14:30:49 No numbers were extracted from the vCard
– END OUTPUT —
Now it makes no sense to me because the xml looks fine and the XPath expression I use looks fine as well.
Any suggestions as to why vcard.getVCard(user).selectNodes("//TEL/NUMBER") isn’'t returning the elements?
I am using Wildfire 3.0.1.
Message was edited by: sipster