title: Is there any way to pass a DOM Object via an Intent and Parcelable?
body: <p>Is there any way to pass a JAXP Node or Document via an Intent and Parcelable? JAXP doesn't implement Parcelable, so the answer is probably --no. Is there any DOM library that implements Parcelable? Can someone provide a working example of that?</p>
  
  <p>Serialization isn't an option; nasty performance hit. Storing the data in res/xml is not an option: it must eventually (by end of project) be encrypted on disk. Android's "compiled" XML Access Tools do not support decrypting the whole XML. Of course I can do it myself with a class.</p>
  
  <p>Here's my starter code that inflates the XML. My goal is to pass a Node or Document from one ListView to another, effectively drilling down the DOM via Lists.</p>
  
  <p>My Document contains information that all activities need to share. Each activity accesses different Nodes, and extracts new information. I've considered exposing the Document via a global, but I don't think it will be safe for multiple Activities to access it that way.</p>
  
  <p>Also, in the working code below I intend to pass a Node to the second ListActivity rather than a String, just haven't gotten that far.</p>
  
  <pre><code>package com.example
  
  import java.io.File;
  
  import javax.xml.parsers.DocumentBuilder;
  import javax.xml.parsers.DocumentBuilderFactory;
  
  import org.w3c.dom.Document;
  import org.w3c.dom.Node;
  import org.w3c.dom.NodeList;
  
  import android.app.ListActivity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.*;
  import android.widget.AdapterView.OnItemClickListener;
  
  public class JAXPListActivity extends ListActivity {
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          Document doc = null;
          try {
              DocumentBuilderFactory factory = 
                          DocumentBuilderFactory.newInstance();
              DocumentBuilder builder = factory.newDocumentBuilder();
              doc = builder.parse(new File("/sdcard/example.xml"));
  
          } catch (Exception e) {
              e.printStackTrace(); //TO-DO: exception handling
          }
  
          NodeList nodes = doc.getChildNodes();
          String[] nodeList = new String[nodes.getLength()];
  
          for(int i = 0; i&lt;nodes.getLength(); i++) {
              Node node = nodes.item(i);
              nodeList[i] = nodes.item(i).getNodeName();
          }
  
          this.setListAdapter(new ArrayAdapter&lt;String&gt;(this, 
                  R.layout.list_item, 
                  R.id.label, nodeList));
  
          ListView lv = getListView();
  
          lv.setOnItemClickListener(new OnItemClickListener() {
              public void onItemClick(AdapterView&lt;?&gt; parent, View view, 
                          int position, long id) {
  
                  String nodeName = ((TextView) view).getText().toString();
  
                  Intent i = new Intent(getApplicationContext(), 
                                  JAXPNodeListActivity.class);
  
                  i.putExtra("nodeName", nodeName);
                  startActivity(i);
              }
          });
      }
  }
  </code></pre>