Date: 2004-07-21T06:01:55
Editor: DerekLastname <[EMAIL PROTECTED]>
Wiki: Cocoon Wiki
Page: Midlets
URL: http://wiki.apache.org/cocoon/Midlets
added code formatting tags
Change Log:
------------------------------------------------------------------------------
@@ -17,7 +17,7 @@
Putting it all together, in the Midlet, you should create a method like this:
-
+{{{
private XmlParser getParser(String url) {
byte[] xmlByteArray = new byte[2048]; // Assume this size as the max
stream size we can receive
@@ -40,11 +40,13 @@
}
return parser;
}
+}}}
The URL points to the pipeline at the server, which will provide the data in
XML.format.
With the parser, you can parse the contents. Here is an example:
+{{{
protected MiArticle getArticleFromXML(String barcode) {
MiArticle art = new MiArticle();
String url = this.baseURLXML + this.articleByBarcodeXML +
@@ -102,7 +104,7 @@
}
}
-
+}}}
As you see, I am filling in the blanks of an object of class MiArticle, using
tags "Codi", "Barcode" and "Nom" in the XML, received from the server. After
this action, you can display the data at the mobile's screen.
@@ -114,7 +116,7 @@
* Works with PALM Tungsten, with the P800 as modem. Takes a little more time
than the classic way, but this is acceptable.
* Other devices under investigation.
-== Resources
+== Resources ==
The "clue" to the solution was found in the article at
[http://www-106.ibm.com/developerworks/library/wi-parsexml/]