Farhad Aghajanian Farhad Aghajanian - 26 days ago 10
Java Question

how to pass an Element of DOM in xml to another activities

XPath xpath = XPathFactory.newInstance().newXPath();

String expression = "...";

EmParent = (Element) xpath.compile(expression).evaluate(Doc,XPathConstants.NODE);

Intent intent = new Intent(com.FSC.xml.MainActivity.this,com.FSC.xml.FileForm.class);
intent.putExtra("Em", EmParent)

startActivity(intent);

Answer

You can't pass nonParcelable or nonSerializable objects into the Intent. Here is similar question.

But if you know structure of the EmParent class

First, you can create a wrapper class which will extend Parcelable or implement Serializable and converter method which converts EmParent into EmParentWrapper and then pass it into intent.

Second, is to put in the intent data from you element by names(of course if you know it)

    Intent intent = new Intent();
    intent.putExtra("FirstAttr", element.getAttribute("FirstAttr"));
    intent.putExtra("SecondAttr", element.getAttribute("SecondAttr"));