File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do i convert a string to string array

 
Aditya Sirohi
Ranch Hand
Posts: 93
Eclipse IDE Linux VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

This is my first positing on the forum and i am new to Java Programming. I have been using XPath API to parse for some tags in the XML file and write it to the file using File Reader/Writer. The problem is that this line of code:- String result = xPath.evaluate("/su/@id", new InputSource(new FileReader("/net/7.1_TESTFIX_CQ/nt_i386/ShareableEntities/"+j1))); returns string. I want to write this to a string[] so that i can write this to a file. So write now the text file myfile.txt only has one entry which is the last entry, where as it should have more than 100 entries. How do i do that. I am copying the method. Help is very appreciated!!!


Thanks
Aditya




(Edited to reduce the width of the code -- PC)
 
Paul Clapham
Sheriff
Pie
Posts: 20166
24
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Once you tell XPath to lump your results together into a String, there's no easy way to get that mess unscrambled. If you expect XPath to return a nodeset, then tell it you want a nodeset:

Now you will have a list of nodes to iterate over.
 
Aditya Sirohi
Ranch Hand
Posts: 93
Eclipse IDE Linux VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Paul,

The suggestion you gave me, i could find a work around with that, so what i did, i wrote i different method which stored the path to the XML file in the text file. I modified this method i posted above to get the valie from the "id" attribute and store it the the test file sucessfully.

Thanks
Aditya
 
Aditya Sirohi
Ranch Hand
Posts: 93
Eclipse IDE Linux VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic