J2ME XML解析

时间:2012-12-24 18:38:05

标签: java-me xml-parsing midlet jsr172 jdwp

我还有一个关于“JDWP错误:21”记录的问题:Unexpected JDWP Error 21

我正在尝试使用下面的代码将我从servlet收集的一些XML解析为J2ME MIDlet。到目前为止还没有成功,我认为由于我的HttpConnection上的JDWP错误,InputStream如何填充XML并且一旦解析了Document内的所有内容都为null。

有没有人对JDWP错误有所了解,并且该代码看起来应该有效吗?

在MIDlet中我使用的是JSR-172 API javax.xml.parsers.*

if(d==form1 && c==okCommand)
    {
        // Display Webpage
         webPage = new TextBox(txtField.getString(),
                "",
                100000,
                TextField.ANY
                );
        Display.getDisplay(this).setCurrent(webPage);

        try 
        {
            HttpConnection conn = (HttpConnection)Connector.open("http://localhost:8080/Blogging_Home/Interface?Page=Bloggers&Action=VIEW&Type=XML");
            conn.setRequestMethod(HttpConnection.GET);
            int rc = conn.getResponseCode();
            getConnectionInformation(conn, webPage);
            webPage.setString(webPage.getString() + "Starting....");
            String methodString = getStringFromURL("");
            if (rc == HttpConnection.HTTP_OK) 
            {
                    InputStream is = null;
                    is = createInputStream(methodString);            
                    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();  
                    DocumentBuilder builder;  
                    Document document;
                    try  
                    {  
                        builder = factory.newDocumentBuilder(); 
                        document = builder.parse(is);  
                    } catch (Exception e) {  
                        e.printStackTrace();  
                    }
            }
            else 
            {
                    webPage.setString(webPage.getString() + "ERROR:" + rc);
            }

        }
        catch(Exception ex)
        {
            // Handle here
            webPage.setString("Error" + ex.toString());
        }

0 个答案:

没有答案