i have a function which in this function, i use Xpath to get the position of a node as below:
Node goTo;
.....
private Node xpathgo(Node node) throws XPathExpressionException {
XPath xpath = XPathFactory.newInstance().newXPath();
Node result;
if (node == null || node.getNodeName() == null){
return null;
}
xpathgo(node.getFirstChild());
result = (Node) xpath.evaluate("//*[. = \"" + goTo.getNodeValue() + "\"]", node,XPathConstants.NODE);
xpathgo(node.getNextSibling());
return result;
}
basically i use this to get a node of a DOM which made from a URL html code, but i face two problems with it, firstly, sometimes i get this exception:
Exception in thread "main" java.lang.RuntimeException: Could not resolve the node to a handle
at com.sun.org.apache.xml.internal.dtm.ref.DTMManagerDefault.getDTMHandleFromNode(DTMManagerDefault.java:574)
at com.sun.org.apache.xpath.internal.XPathContext.getDTMHandleFromNode(XPathContext.java:182)
at com.sun.org.apache.xpath.internal.XPath.execute(XPath.java:301)
at com.sun.org.apache.xpath.internal.jaxp.XPathImpl.eval(XPathImpl.java:210)
at com.sun.org.apache.xpath.internal.jaxp.XPathImpl.evaluate(XPathImpl.java:275)
and also this one for some other kind of nodes:
Caused by: javax.xml.transform.TransformerException: Expected ], but found: the
at com.sun.org.apache.xpath.internal.compiler.XPathParser.error(XPathParser.java:608)
at com.sun.org.apache.xpath.internal.compiler.XPathParser.consumeExpected(XPathParser.java:526)
at com.sun.org.apache.xpath.internal.compiler.XPathParser.Predicate(XPathParser.java:1935)
at com.sun.org.apache.xpath.internal.compiler.XPathParser.Step(XPathParser.java:1724)
at com.sun.org.apache.xpath.internal.compiler.XPathParser.RelativeLocationPath(XPathParser.java:1624)
at com.sun.org.apache.xpath.internal.compiler.XPathParser.LocationPath(XPathParser.java:1595)
at com.sun.org.apache.xpath.internal.compiler.XPathParser.PathExpr(XPathParser.java:1315)
at com.sun.org.apache.xpath.internal.compiler.XPathParser.UnionExpr(XPathParser.java:1234)
at com.sun.org.apache.xpath.internal.compiler.XPathParser.UnaryExpr(XPathParser.java:1140)
at com.sun.org.apache.xpath.internal.compiler.XPathParser.MultiplicativeExpr(XPathParser.java:1061)
at com.sun.org.apache.xpath.internal.compiler.XPathParser.AdditiveExpr(XPathParser.java:1003)
at com.sun.org.apache.xpath.internal.compiler.XPathParser.RelationalExpr(XPathParser.java:928)
at com.sun.org.apache.xpath.internal.compiler.XPathParser.EqualityExpr(XPathParser.java:868)
at com.sun.org.apache.xpath.internal.compiler.XPathParser.AndExpr(XPathParser.java:832)
at com.sun.org.apache.xpath.internal.compiler.XPathParser.OrExpr(XPathParser.java:805)
at com.sun.org.apache.xpath.internal.compiler.XPathParser.Expr(XPathParser.java:788)
at com.sun.org.apache.xpath.internal.compiler.XPathParser.initXPath(XPathParser.java:127)
at com.sun.org.apache.xpath.internal.XPath.<init>(XPath.java:176)
at com.sun.org.apache.xpath.internal.XPath.<init>(XPath.java:264)
at com.sun.org.apache.xpath.internal.jaxp.XPathImpl.eval(XPathImpl.java:193)
at com.sun.org.apache.xpath.internal.jaxp.XPathImpl.evaluate(XPathImpl.java:275)
... 7 more
but the funny thing is, in booth cases, the nodes are a [#text] node which made me confused why it happens.
I've made a function that returns the position of the node as you want :
test.xml
<html>
<div id='teste'>Teste</div>
<div id='poutine'>poutine</div>
<div id='ola'>Ola tudo ebm!</div>
</html>
XMLManager Class :
public final class XMLManager {
public static Integer getPositionByNode(Node node, File filteForLookUp){
Integer position = null;
try {
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(filteForLookUp);
NodeList ndList = doc.getElementsByTagName("*");
if(ndList != null){
for(int i=0;i<ndList.getLength();i++){
if(ndList.item(i).isEqualNode(node)){
position = i;
System.out.println("Dans la condition");
}
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return position;
}
}
my Main :
public class MyMain {
/**
* #param args
*/
public static void main(String[] args) {
Document doc = null;
File file = new File("D:\\Loic_Workspace\\Test2\\res\\test.xml");
try {
doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(file);
System.out.println(doc.getElementsByTagName("*").item(2).getTextContent());
System.out.println(XMLManager.getPositionByNode(doc.getElementsByTagName("*").item(2), file));
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Output in the console :
poutine
Dans la condition
2
By the way is not weird to get [#text], you can't get the value by getTextContent() method.
Hope it's helps ;)
Related
I have this spring boot java controller having code that utilizes the OpenKM document management API to search the document management system for documents and display results using Ajax, HTML, CSS and Jquery datatables on the front-end.
Due to the way the API was written, I cannot get a document object with its metadata in one call but will need to use an output of the first API operation's call as a filter for another API operation method in two nested for loops.
Additionally, I had to iterate the toString method of an API return object to retrieve the metadata information, as they were not accessible through the return object's properties.
The problem is the performance of this code. I would like to see if there is a way to optimize this code.
// Read the property or metadata to use in constituting the StoredDocument object
for (QueryResult queryResult : resultSet.getResults()) {
// Create a locally-scoped List<String>
List<String> listOfStoredDocumentProperties = new ArrayList<String>();
Document document = queryResult.getDocument();
String nodeId = document.getPath();
// Populate storedDocument object
storedDocument = new StoredDocument();
storedDocument.setAuthor(document.getAuthor());
storedDocument.setCreated(document.getCreated());
storedDocument.setLastModified(document.getLastModified());
storedDocument.setPath(document.getPath());
storedDocument.setPermissions(document.getPermissions());
storedDocument.setSize(document.getActualVersion().getSize());
storedDocument.setUuid(document.getUuid());
storedDocument.setVersionNumber(document.getActualVersion().getName());
// System.out.println(nodeId);
try {
listOfFormElement = okm.getPropertyGroupProperties(nodeId, documentVo.getGroupId());
int counterForTrackingDocDirectionPos = 0;
for (FormElement formElement : listOfFormElement) {
++counterForTrackingDocDirectionPos;
if (counterForTrackingDocDirectionPos == 4) {
String formElementString = formElement.toString();
// System.out.println("formElementString: " + formElementString);
System.out.println("name: " + formElement.getName());
System.out.println("formElement: " + formElement);
String transformedFormElementString = StringUtils.EMPTY;
try {
transformedFormElementString = formElementString.substring(0, formElementString.indexOf(", selected=true"));
// Read the string from a position that is 3 steps before the last position in the string.
transformedFormElementString = transformedFormElementString
.substring(transformedFormElementString.length() - 3, transformedFormElementString.length()).trim();
transformedFormElementString = transformedFormElementString.startsWith("=")
? transformedFormElementString.substring(1, transformedFormElementString.length()) : transformedFormElementString;
} catch (Exception ex) {
// To catch scenario where formElementString.indexOf(", selected=true") does not find the
// specified string. This happens when document direction is not set and therefore is
// selected=false for both the options IN and OUT.
transformedFormElementString = "NOT SET";
}
listOfStoredDocumentProperties.add(transformedFormElementString);
System.out.println("transformedFormElementString: " + transformedFormElementString);
} else {
String formElementString = formElement.toString();
String transformedFormElementString = formElementString.substring(formElementString.indexOf("value="),
formElementString.indexOf("data="));
// Remove the preceding 'value=' and the last 2 character-constituted string ", "
transformedFormElementString = transformedFormElementString.substring(6, transformedFormElementString.length() - 2).trim();
listOfStoredDocumentProperties.add(transformedFormElementString);
}
}
storedDocument.setCompanyName(listOfStoredDocumentProperties.get(0));
storedDocument.setProductLine(listOfStoredDocumentProperties.get(1));
storedDocument.setSubjectHeading(listOfStoredDocumentProperties.get(2));
storedDocument.setDocumentDirection(listOfStoredDocumentProperties.get(3));
storedDocument.setDocumentType(listOfStoredDocumentProperties.get(4));
storedDocument.setReferenceNumber(listOfStoredDocumentProperties.get(5));
storedDocument.setDate(ISO8601.parseBasic(listOfStoredDocumentProperties.get(6)).getTime().toString());
// Add the storedDocument object to the return list
listOfstoredDocuments.add(storedDocument);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchGroupException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (PathNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RepositoryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (DatabaseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnknowException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (WebserviceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
The solution for it is extending the REST API. In the professional edition, the REST API is extensible with plugins architecture https://docs.openkm.com/kcenter/view/okm-6.4/creating-your-own-rest-plugin-(-extending-rest-api-).html, in the community this option still is not present. The idea is to build a method from server side what provide the exact data what really you need, creating high-level methods.
I'm trying to parse json (steam webchat) which looks like that (I've changed response cause I don't wanna show the data):
/**/({
"pollid": 00,
"messages": [
{
"type": "personastate",
"timestamp": 0000000000,
"utc_timestamp": 000000000,
"steamid_from": "000000000000",
"status_flags": 0000000,
"persona_state": 0,
"persona_name": "asd"
}
]
,
"messagelast": 00,
"timestamp": 0000000000,
"utc_timestamp": 000000000000,
"messagebase": 00,
"sectimeout": 0,
"error": "OK"
})
And my parsing class looks like that:
package jsonRequest;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
public class NewMessageJson {
public Integer poollid;
private String lastMessageId;
private String error;
private String messageBase;
public NewMessageJson(String response) {
response = response.substring(response.indexOf("{"),
response.indexOf("}") + 1); // cut off comment block
JsonFactory factory = new JsonFactory();
JsonParser jp = null;
try {
jp = factory.createJsonParser(response);
} catch (JsonParseException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
if (jp.nextToken() != JsonToken.START_OBJECT) {
throw new IOException("Server didn't return any data");
}
while (jp.nextToken() != JsonToken.END_OBJECT) {
String fieldName = jp.getCurrentName();
jp.nextToken();
if (fieldName.equals("messagelast")) {
setLastMessageId(jp.getText());
} else if (fieldName.equals("pollid")) {
setPoollid(jp.getIntValue());
} else if (fieldName.equals("messagebase")) {
setMessageBase(jp.getText());
} else if (fieldName.equals("error")) {
setError(jp.getText());
}
}
jp.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NullPointerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
jp.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public Integer getPoollid() {
return poollid;
}
public void setPoollid(Integer poollid) {
this.poollid = poollid;
}
public String getLastMessageId() {
return lastMessageId;
}
public void setLastMessageId(String lastMessageId) {
this.lastMessageId = lastMessageId;
}
public String getError() {
return error;
}
public void setError(String error) {
this.error = error;
}
public String getMessageBase() {
return messageBase;
}
public void setMessageBase(String messageBase) {
this.messageBase = messageBase;
}
}
And when it comes to the line
if (fieldName.equals("messagelast")) {
It crashes and returns NPE.
I have 3 other classes looking exactly like this one and everything works perfectly.
I am pretty sure the reason you are getting the NPE is because you initially instantiate JsonParser jp as null. You assign it to factory.createJsonParser(response) in your try block but do not deal with the error in any way besides printing the stack trace. If there was an error executing factory.createJsonParser(response), you need to make sure nothing else runs.
I would suggest changing your code to this:
...
JsonFactory factory = new JsonFactory();
JsonParser jp = null;
try {
jp = factory.createJsonParser(response);
} catch (JsonParseException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
System.out.println("There was an error while setting jp to factory.createJsonParser(response). Error message is: " + e1.getMessage());
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
System.out.println("There was an error while setting jp to factory.createJsonParser(response). Error message is: " + e1.getMessage());
}
if(jp != null) {
try {
if (jp.nextToken() != JsonToken.START_OBJECT) {
throw new IOException("Server didn't return any data");
}
while (jp.nextToken() != JsonToken.END_OBJECT) {
String fieldName = jp.getCurrentName();
jp.nextToken();
if (fieldName.equals("messagelast")) {
setLastMessageId(jp.getText());
} else if (fieldName.equals("pollid")) {
setPoollid(jp.getIntValue());
} else if (fieldName.equals("messagebase")) {
setMessageBase(jp.getText());
} else if (fieldName.equals("error")) {
setError(jp.getText());
}
}
jp.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NullPointerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
jp.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
...
This way, you can avoid all NPEs!
EDIT: You should also implement what peeskillet suggested
I have an string which I am attempting to extract values from, for convenience I thought that converting the string to a Document and then parsing the xml would be the best way to do this but I am running into all sorts of problems! The string looks like:
<Messagexxx>
<Unit>
<contact>0</contact>
<text>Test Content</text>
<date>09-Sep-14 13:56</date>
<subject>Test Title</subject>
</Unit>
</Messagexxx>
Can someone point me in the correct way to achieve my goal of reading the values from the tags .
I have attempted using the following snippet but I all the values in the array are
null! Document xml = null; Node T = null; try { xml = stringToDom(message); T = xml.getLastChild(); } catch (SAXException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ParserConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } if(xml.getFirstChild() != null){ }
When you write your string to a text file, you can first parse it:
private Document parse(String filename){
Document doc = null;
try {
DOMParser parser = new DOMParser();
parser.parse(filename);
doc = parser.getDocument();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return doc;
}
and then you read all text elements out of this document:
public void extract (Document doc){
Node root = doc.getDocumentElement();
for (int i = 0; i< root .getChildNodes().getLength(); i++){
Node child = root.getChildNodes().item(i);
System.out.println(child.getTextContent());
}
}
Use JAXB lib : https://jaxb.java.net/
Create your model from your XML and to read :
JAXBContext jaxbContext = JAXBContext.newInstance(YourModel.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
StringReader reader = new StringReader("xml string here");
YourModel yourModel= (Person) unmarshaller.unmarshal(reader);
After your can use the object "YourModel" to read your value.
This is a very simple way to get node values when you know the node names, and they don't repeat:
String getXmlNodeValue(String xmlString, String nodeName){
int start = xmlString.indexOf("<"+nodeName+">") + nodeName.length() + 2;
int end = xmlString.indexOf("</"+nodeName+">");
return xmlString.substring(start, end);
}
I am reading in an XML file, and trying to return the values in another class using Java. In the XML Reader I read in the values from the XML file. I'm not quite sure how to do this. Any help would be appreciated.
public class XMLReader {
public static List<String> load()
{
try{
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.parse (new File("C:/adapters.xml"));
doc.normalize();
NodeList rootNodes = doc.getElementsByTagName("adapters");
Node rootNode = rootNodes.item(0);
Element rootElement = (Element) rootNode;
NodeList adaptersList = rootElement.getElementsByTagName("class");
for(int i=0; i<adaptersList.getLength(); i++){
Node theAdapter = adaptersList.item(i);
Element adpElement = (Element) theAdapter;
System.out.println("This is: " + adpElement.getTextContent());
}
}catch(ParserConfigurationException e){
e.printStackTrace();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}
public class AdapterLoader {
public static List<AbstractAdapter> loadAllAdapters()
{
List<AbstractAdapter> allAdapters = new ArrayList<AbstractAdapter>();
List<String> adapterClasses = XMLReader.load();
for (String className : adapterClasses)
{
try {
Class adapters = Class.forName(className);
AbstractAdapter adp = (AbstractAdapter) adapters.newInstance();
allAdapters.add(adp);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return allAdapters;
}
}
Instead of printing it to console
System.out.println("This is: " + adpElement.getTextContent());
add this to a List and return that instead of
return null;
I'm trying to make a new thread for parsing xml from an rss feed. When I click run it says there are errors please correct them etc. I have 2 classes in my project. The other class has no errors and this class below has only warnings that a lot of the things in the try/catch statements may be uninitialized. I understand that and figured I should still be able to run the program anyways, I expect them to be initialized and if they're not that's fine I want to know about it. Is this really what's going on or am I missing something? I thought it would compile if something may be uninitialized but its not certainly uninitialized.
public class RssParse extends Thread {
Thread th=new Thread() {
public void run(){
System.out.println("1");
URL iotd;
try {
iotd = new URL("http://www.nasa.gov/rss/image_of_the_day.rss");
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("2");
BufferedReader in;
try {
in = new BufferedReader(new InputStreamReader(iotd.openStream()));
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
System.out.println("3");
XmlPullParserFactory factory;
try {
factory = XmlPullParserFactory.newInstance();
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
factory.setNamespaceAware(true);
System.out.println("4");
XmlPullParser xpp;
try {
xpp = factory.newPullParser();
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("5");
try {
xpp.setInput(in);
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("6");
int eventType;
try {
eventType = xpp.getEventType();
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(eventType+"!!!!!!!!!!!!!!!!");
while(eventType!=XmlPullParser.END_DOCUMENT){
if(eventType==XmlPullParser.START_DOCUMENT){
System.out.println("start");
}
}
try {
in.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}//method
};//thread
}//class
Look at this try/catch block for example :
URL iotd;
try {
iotd = new URL("http://www.nasa.gov/rss/image_of_the_day.rss");
} catch (MalformedURLException e) {
e.printStackTrace();
}
If iotd = new URL("...") fails, iotd will remain uninitialized.
There are two ways to deal with this :
Assign a default value to iotd, like : URL iotd = null; However, it's bad here because if you use iotd later its value may be null and can throw a NullPointerException.
Stop the execution of your function if something failed instead of just printing the stack trace. For example you can add a return statement in the catch block :
URL iotd;
try {
iotd = new URL("http://www.nasa.gov/rss/image_of_the_day.rss");
} catch (MalformedURLException e) {
e.printStackTrace();
return;
}
All the warnings you are getting are because all your catch blocks are not dealing with the exception at all (just printing the stacktrace to standard out).
Let's see it through an example:
URL iotd;
try {
iotd = new URL("http://www.nasa.gov/rss/image_of_the_day.rss");
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
at that snipped you are declaring a iotd variable as a URL but without initializing it (not assigning any value), you do it inside the try block - which isn't wrong by the way. However if for any reason the statement inside the try block throws an exception program flow will go to the catch block leaving the iotd variable with its initial value (unassigned).
So, in that case, execution of the program will continue and when reaching this statement:
in = new BufferedReader(new InputStreamReader(iotd.openStream()));
it will find no value assigned to the iotd variable.
To remove the warning regarding the uninitialized value you can either assign a null value to the variable when declaring it or rethrow another exception inside the catch block, stopping the program flow.
In the other hand, the snippet you posted here is not just one class, it's actually two as you are extending the Thread class and then creating an anonymous one inside its body. Using threads is easier than that in Java, just implement the Runnable interface and then instantiate a new thread from that interface:
public class MyRunnable implements Runnable {
public void run() {
// do stuff
}
}
and then:
new Thread(new MyRunnable()).start();
cheers
you need to initialize the variables above the try catch block, or give them a value in catch or finally block
find updated code here
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
public class RssParse extends Thread {
Thread th=new Thread() {
public void run(){
System.out.println("1");
URL iotd=null;
try {
iotd = new URL("http://www.nasa.gov/rss/image_of_the_day.rss");
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("2");
BufferedReader in=null;
try {
in = new BufferedReader(new InputStreamReader(iotd.openStream()));
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
System.out.println("3");
XmlPullParserFactory factory=null;
try {
factory = XmlPullParserFactory.newInstance();
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
factory.setNamespaceAware(true);
System.out.println("4");
XmlPullParser xpp=null;
try {
xpp = factory.newPullParser();
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("5");
try {
xpp.setInput(in);
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("6");
int eventType=-1; // set to a default value of your choice
try {
eventType = xpp.getEventType();
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(eventType+"!!!!!!!!!!!!!!!!");
while(eventType!=XmlPullParser.END_DOCUMENT){
if(eventType==XmlPullParser.START_DOCUMENT){
System.out.println("start");
}
}
try {
in.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}//method
};//thread
}//class