开发者

BlackBerry - Modify innnet text of node in xml file

I am working on blackberry java development. I am having a xml file:

<?xml version="1.0" encoding="UTF-8"?>
<settings>
    <url>www.test.com</url>
    <username>testuser</username>
    <password>sun123ARC</password>
    <width>350</width>
    <height>350</height>
</settings>

I want to cha开发者_如何学编程nge the inner text of all nodes. After saving when I open the xml file again, the saved data should open. How can I do that?


You don't mention what this is for in your question, but if your goal is to persist configuration data for your app, you may also want to look into using the PersistentStore API instead of storing XML files to the filesystem. No third-party libraries requires and it only takes a few lines of code.


I see two options:

  • use kxml (you will need to import 3dr party lib). See Better approach for XML Creation in Blackberry
  • implement custom parser to search and replace text reading String from InputStream, and saving back to OutputStream. See J2ME/Blackberry - how to read/write text file? for file io sample and StringMatch API for search implementation.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜