I'm currently working with GWT trying to pull my gmail contacts and
display them, my question is why doesn't this piece of code work
[code]public void displayMyItems(String token) {
try{
System.out.println("display items try");
HttpURLConnection connection = (HttpURLConnection)(new URL
(ITEMS_FEED)).openConnection() ;
// Set properties of the connection
connection.setRequestMethod("GET");
connection.setRequestProperty("Authorization", "GoogleLogin
auth=" + token);
connection.setRequestProperty("X-Google-Key", "key=" + "");
int responseCode = connection.getResponseCode();
InputStream inputStream;
if (responseCode == HttpURLConnection.HTTP_OK) {
inputStream = connection.getInputStream();
System.out.println("ipstream");
} else {
inputStream = connection.getErrorStream();
System.out.println("ipstream error");
}
System.out.println("error11");
System.out.println("here we go " + toString(inputStream));
String xml = toString(inputStream);
System.out.println("STRINGGFGHFGH");
Document xmlDoc = null;
System.out.println("doc");
xmlDoc = XMLParser.parse(xml);
System.out.println
("XXXXXXXXXXXXMMMMMMMMMMMMLLLLLLLLLLLDDDDDDDDDOCCCCCCC");
Element root = xmlDoc.getDocumentElement();
System.out.println("root");
XMLParser.removeWhitespace(xmlDoc);
System.out.println("after white space removal");
NodeList URLs = (NodeList) root.getChildNodes();
System.out.println("Urls" + URLs);
System.out.println("lenght" + URLs.getLength());
String html = "<ol>";
for(int i = 0; i < URLs.getLength(); i++){
Element thisElement = (Element) URLs.item(i);
System.out.println("Element" + thisElement);
if (thisElement.getNodeName().equals("email")){
Element linkElement = (Element)
thisElement.getFirstChild();
//String link = linkElement.getFirstChild().getNodeValue
();
Element titleElement = (Element)
linkElement.getNextSibling();
//String title = titleElement.getFirstChild
().getNodeValue();
Element linkElement2 = (Element)
linkElement.getNextSibling();
System.out.println("WWWWWWWWWWWWWWWWWWWWW" +
linkElement2.getNodeValue().toString());
}
}[/code]
it gets to here xmlDoc = XMLParser.parse(xml); and then stops
But this piece of code does work
[code]public void onCompletion(String responseText) {
System.out.println("Gmail Initiated");
Document xmlDoc = XMLParser.parse(responseText);
System.out.println("document got");
Element root = xmlDoc.getDocumentElement();
XMLParser.removeWhitespace(xmlDoc);
System.out.println("after white space removal");
NodeList URLs = (NodeList) root.getChildNodes();
System.out.println("Urls" + URLs);
System.out.println("lenght" + URLs.getLength());
String html = "<ol>";
for(int i = 0; i < URLs.getLength(); i++){
Element thisElement = (Element) URLs.item(i);
System.out.println("Element" + thisElement);
if (thisElement.getNodeName().equals("email")){
Element linkElement = (Element)
thisElement.getFirstChild();
//String link = linkElement.getFirstChild
().getNodeValue();
Element titleElement = (Element)
linkElement.getNextSibling();
String title = titleElement.getFirstChild
().getNodeValue();
html += "<li><a href=\"" + title + "\">" + title +
"hello"+ "</a></li>";
System.out.println("title" + title);
}
}[/code]
Its really wrecking my heading and google has yielded nothing, I can
print the input stream out as a string so it is getting set to a
string but when i try to use the Xml Parser on it it just doesn't
display anything
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"GWT-Ext Developer Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/gwt-ext?hl=en
-~----------~----~----~----~------~----~------~--~---