Jsoup is generally used for parsing html, not xml, although they have same structure. By default, Jsoup parses anything, then wraps it inside html.
Up vote 0 down vote favorite share g+ share fb share tw.
I am trying to create the following example. Testname blaat.. I try this by doing the following: FileInputStream fis = openFileInput("test1. Xml"); Document doc = Jsoup.
Parse(fis, "UTF-8", ""); Node node = doc. GetElementsByTag("item"). Get(getPosition()); fis.close(); fis = openFileInput("test2.
Xml"); Document doc2 = Jsoup. Parse(fis, "UTF-8", ""); fis.close(); Elements test = doc2. GetElementsByTag("resources"); if(test.size() Testname blaat.. Next item Testname blaat.. Can anybody tell me what i'm doing wrong and maybe give me some examples on how it should be done?
Thanks in advance EDIT: To give a bit more detail: I want to copy some items from test1. Xml to test2.xml. So basically the user selects a listitem that points to a number in text1.
Xml (item number) and that item should then be copied into the (ITEM HERE java android xml jsoup link|improve this question edited Mar 1 at 15:12 asked Mar 1 at 13:15stackr1,223215 83% accept rate.
First, clean up your code by removing things that don't matter and naming variables in a more self-documenting way. (eg. If(test.size() But those comments are not very helpfull i'm afraid.
– stackr Mar 1 at 15:00 Can you post what is in test2. Xml? Also, jsoup is more suited to HTML parsing versus XML parsing, but you might be able to get this to work.
– B. Anderson Mar 1 at 15:03 I added a bit more information. Test2.
Xml is like an output document. Test1. Xml has information that should be able to be copied into test2.
Xml when the user requests – stackr Mar 1 at 15:14.
Jsoup is generally used for parsing html, not xml, although they have same structure. By default, Jsoup parses anything, then wraps it inside .... An example for your goal: import org.jsoup.nodes. *; Document doc = Jsoup.
Parse(""); // clear doc. Html(""); Element e = doc. AppendElement("body").
AppendElement("resources"); e = e. AppendElement("string-array"); e. Attr("name", "mytest"); for (int I = 0; I AppendElement("item"); sub.
Attr("number", Integer. ToString(i)); sub. AppendElement("name").
Text("blahh"); } References: parse(String) html(String) appendElement(String) attr(String, String) text(String).
This doesn't solve your exact problem, but you should be able to figure it out from here. I do pretty much create test2. Xml as a new document.
So, if that exists with information in it, you will have to work around that. String html = "" + "" + "" + "Testname" + "" + "" + "blaat.." + "" + "" + "Next item" + "" + "" + ""; Document test1 = Jsoup. Parse(html); Document test2 = Jsoup.
Parse(""); test2.body(). Append(""); test2. Select("resources").
Append(""); test2. Select("name=mytest"). Append(test1.
Select("itemnumber=1").toString()); test2. Select("name=mytest"). Append(test1.
Select("itemnumber=2").toString()); System.out. Println(test2.body().children()); Here is the output: Testname blaat..
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.