pls i want to know what i must use to read xml file in remote machine in java.
is it possible using saaj,or other.i have jdk 1.6 installed on window 7 os machine.
what also suitable softwares for this task.
apreciate any ideas

Recommended Answers

All 4 Replies

thanx i've read about it,and i will try it,but i've found only code related to .xml file that resides on local machine.what if i want to read or write xml file that resides on remote machine
how can i replace the red line in this example
example:

public static void main(String[] args) { 
                SAXBuilder sb = new SAXBuilder(false); 
                Document d = null; 
                try { 
                        d = sb.build(new File("c:/formatxml.xml"));                         XMLOutputter outputter = new XMLOutputter(); 
                        outputter.output(d, System.out); 
                } catch (JDOMException e) { 
                        e.printStackTrace(); 
                } catch (IOException e) { 
                        e.printStackTrace(); 
                } 
  
                //Root element 
                Element elemen = d.getRootElement(); 
  
                //Child elements (children) 
                List elements = elemen.getChildren(); 
                Iterator i = elements.iterator(); 
  
                System.out.println(elemen.getChild("courses").getChild("course").getAttributeValue("id")); 
                //Iterate childs 
                while (i.hasNext()) { 
                        Element element = (Element) i.next(); 
                        System.out.println("course:"+ element.getChildText("course")); 
                } 
        }

thanx

Well you need to have a way for user to enter location of the file to be open/saved. So depending on sort of application you building command line/GUI/web you need to ask user to provide it for you. Obviously if it is remote location you would need to be ready to also pass login details

than for reply
i mean this is not a problem i can know the path of the file that the user resides,for example if it is in c:\java and the static ip address is:41.70.185.160
what must i edit in my code
best regards

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.