xml - Xpath in java for array of values -


i have following problem. im using xpath extract value xml file using java program

<place>  <native name= "aaaaaa" /> <native name= "bbbbbb" /> <native name= "cccccc" /> <native name= "dddddd" /> <native name= "eeeeee" /> </place> 

above partial xml file. im using following xpath

/root/place/native/@name /root/home /root/xxxxxx 

and want result

aaaaaa|bbbbbbb|ccccccc|ddddddd|eeeeeeeˆevergreenˆvaluesˆexample 

how can . can 1 me

for (string temp : xpathvalue) {               tempflat = xpath1.compile(temp).evaluate(xmldocument);                         tempflat1 = tempflat.replaceall("\\s+", " ");                         value1.append(tempflat1);                         value1.append((char)"ˆ"); 

xpathexpression#evalute return nodelist if use xpathconstants.nodeset.

once have nodelist, need iterate list , populate array...

nodelist nodelist = (nodelist)xpath1.compile("/place/native[@name]").evaluate(xmldocument, xpathconstants.nodeset); string[] results = new string[nodelist.getlength()]; (int index = 0; index < nodelist.getlength(); index++) {     node node = nodelist.item(index);     string name = node.getattributes().getnameditem("name");     results[index] = name; } 

Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -