Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public String GetXmlData()
- {
- DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
- DocumentBuilder builder = null;
- try
- {
- builder = builderFactory.newDocumentBuilder();
- InputStream is = getAssets().open("words.xml");
- Document document = builder.parse(new FileInputStream("C:\Users\Ocean\AndroidStudioProjects\Deneme1Project\Deneme1\build\res\assets\words.xml"));
- Element rootElement = document.getDocumentElement();
- NodeList nodes = rootElement.getChildNodes();
- for(int i=0; i<nodes.getLength(); i++){
- Node node = nodes.item(i);
- if(node instanceof Element)
- {
- //a child element to process
- Element child = (Element) node;
- title = child.getAttribute("title");
- String author= child.getAttribute("author");
- String year= child.getAttribute("year");
- }
- }
- return title;
- }
- catch (Exception e)
- {
- e.printStackTrace();
- return e.toString();
- }
- }
- Document document = builder.parse(new FileInputStream("C:\Users\Ocean\AndroidStudioProjects\Deneme1Project\Deneme1\build\res\assets\words.xml"));
- getAssets().open("words.xml");
- File wordsXML = new File(Environment.getExternalStorageDirectory() + "/SomeFolderName/" + "words.xml");
- FileInputStream fis = new FileInputStream(wordsXML);
- FileInputStream fis =(FileInputStream) getResources.openRawResource(R.raw.words);
- InputStream is = (InputStream) getAssets().open("words.xml");
- FileInputStream fis =(FileInputStream) getResources.openRawResource(
- R.raw.words);
- Document document = builder.parse(new FileInputStream(fis));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement