Traversing through xml file

can anybody will tell me how can i access n print the particular node in xml file through DOM api in java(not DOMParser of XERCES)

use utility classes like DOMwriter available with most of the parsers

Similar Messages

  • Send Image through xml file

    Hey guys,
    I want to send an JPEG image through xml file. i dont want to just give the URL of the image but i want to actually send the image through xml. Im new in XML so can you please give me a working sample code.
    Thank you so much.

    Working code will not be difficult to write. Jpeg or other binary info can be encoded in xml using base64 encoding or some other encoding algorithm.
    After base64 encoding you will get some text which will be the base64 equivalent of the image data. This text can be placed in CDATA section of your image element and transferred.
    On the receiving end you will need to decode the text. After this what u have is the binary data for ur image.
    It will not be difficult to find libraries for base64 encodin/decoding on the net.
    Hope it helps

  • Update Database Through XML file using SAP B1 business objects

    Hello everyone,
    I am facing a problem ie I am not able to update the Database(SQL 2000) through an XML file.
    Though i am able to insert the data in the databse using xml file but unable to update that data.
    The tables i want to update are OITM,ITM1,OITW. While i was trying to update  the Databse i was getting an error ie " -1107 Object's key is not set".
    I dont want to use DTW for importing or anything.
    Kindly help me out why i am facing this problem asap...

    Hi Pranay,
    My case was that I wanted to replicate an item from one company to another (I guess that's your case also). What I finally did is copy field by field the objects I needed. Later I've find out the solution given here,
    Copy items between databases
    but I haven't try it out. I expect your comments about it :).
    Regards,
    Ian

  • Import and Export CSV Through XML File in Oracle

    Hi Gurus,
    I am sorry , I had deleted this post.
    Thanks
    Edited by: user10679113 on Feb 5, 2009 6:13 AM

    What does it mean to do something with comma separated values through XML. That is a new concept for me.
    Either something is CSV or XML but what is it you are trying to describe? Please provide an example.
    Then come the obvious questions like what version and edition of Oracle on what platform? What does any of this have to do with email? How large a file? etc.
    No one else has responded so I can only assume they are thinking what I am ... "what is this person trying to do?"

  • AS3.0 iterating through XML file

    I am new to AS3.0 and the new E4X way of working with XML.
    I'm trying to loop through a portion of an externally loaded XML
    file and display the results. Here is a portion of my XML file:
    <amenity id="1">
    <title>The Gate House</title>
    <feature>Majestic two-level Preserve Neighborhood
    Amenity Center</feature>
    <feature>Beautiful Gardens and Meandering
    Pathways</feature>
    <feature>Meeting Activity Room, Theatre Room, Gourmet
    Kitchen, Hearth Room, Grand Fireplace</feature>
    <feature>Decks and Patios</feature>
    <feature>Available to residents for parties, reunions,
    weddings, and meetings</feature>
    </amenity>
    The are other amenities as well. When a user clicks a button,
    I want to enumerate all of the features from this particular
    amenity. Here is my code to do this (the code associated with the
    listener for the button):
    function btnClick(eventObject) {
    var mc:MovieClip=eventObject.target
    var num:String = mc.name.replace("btn","")
    var xmlAmenity:XMLList = myXML.amenity.(@id==num)
    for each (var prop:XML in xmlAmenity) {
    trace (prop.feature);
    Basically the button that calls this is btn1, so the num
    variable ends up being 1. myXML is a global variable into which the
    external XML file has already been loaded. It then uses the num
    variable to assign the amenity with an id if 1 to the xmlAmenity
    variable as an XMLList. Everything works just grand except for the
    fact that the trace produces the following:
    <feature>Majestic two-level Preserve Neighborhood
    Amenity Center</feature>
    <feature>Beautiful Gardens and Meandering
    Pathways</feature>
    <feature>Meeting Activity Room, Theatre Room, Gourmet
    Kitchen, Hearth Room, Grand Fireplace</feature>
    <feature>Decks and Patios</feature>
    <feature>Available to residents for parties, reunions,
    weddings, and meetings</feature>
    I don't want the tags, just what's inside them. Is there some
    property I need to use (something like prop.feature.contents) or am
    I going about this the wrong way entirely? I suppose I could
    restructure my XML file to put the contents of the feature tag in
    an attribute called description and then trace the attribute with
    prop.feature.@description, but I'd kind of like to know how to
    access the text inside the open and close of the tag. If I access
    one directly (something like myXML.amenity.(@id==num).feature[0])
    then it works just fine, I just can't seem to figure it out in a
    loop. I suppose I could increment a variable and do something like
    trace(myXML.amenity.(@id==num).feature[x]), but there must be a
    better way.

    Goodness sakes, that was a long post for a quick answer I
    just figured out:
    My loop should read like this:
    for each (var prop:String in xmlAmenity.feature) {
    trace (prop);
    The key was enumerating through each xmlAmenity.feature, not
    xmlAmenity. Of course, if there's a better way, I'm all
    ears...

  • Configuring SPA2102 through xml file

    Can anyone help me? I have an SPA2102 and i want to configure it through an xml file, but it doesnt seem to work, the xml im sending is the following:
    <flat-profile>
    <User_ID_1_>user</User_ID_1_>
    <Password_1_>password</Password_1_>
    </flat-profile>
    Since all i want to change is the account, but when i load it with the http://ipaddress/admin/resync?tftp... i get the following message,  SPA will resync the profile when it is not in use and reboot
    you can click HERE to return to the configuration page, but it never reboots,and if i do it manually, it stays the same, so i would appretiate if someone could help me, and point me in the right direction, telling what is that im doing wrong. Thanks in advance. 

    I will try to make it clearer:
    The server I have access to runs Tomcat through Apache. The only way I can access files is if I put them under httdocs.
    The question is quite simple: without having my clueless host remap everything, how can I access files in the Tomcat directory, where those files rightly belong?
    There should be a simple way to do it in a web.xml file, but have been unsuccessful thus far.

  • Trouble looping through XML file

    I've got the following code which loops through an XML file. It works when there are multiple devices in the XML file and the COMPUTER node in the script includes [$i] but if only one device is in the network (thus only one in the XML file) then I have to
    remove the [$i]. What am I doing wrong to make it apply to both?
    $i = 0
    foreach ($COMPUTER in $settings.Settings.Setting.COMPUTERS.COMPUTER) {
    # IP for Computer
    $IPADDRESS = $settings.Settings.Setting.COMPUTERS.COMPUTER[$i].COMPUTERIP
    # Username for Computer
    $USERNAME = $settings.Settings.Setting.COMPUTERS.COMPUTER[$i].USERNAME
    # Credentials file
    $CREDFILE = $settings.Settings.Setting.COMPUTERS.COMPUTER[$i].CRED
    # Do things here using the variables declared above
    $i= $i+1
    } # Stop looping
    I should point out that I've changed the variable and XML names accordingly but the principle is the same.
    Thanks in advance

    Hi Bobbins,
    no, I just pasted that there so you can copy&paste it to the console and see the results. External XML sources are totally valid.
    To apply this to your initial script example, replace all instances of ...
    $settings.Settings.Setting.COMPUTERS.COMPUTER[$i]
    ... with ...
    $COMPUTER
    Cheers,
    Fred
    There's no place like 127.0.0.1

  • Reading the datas in the Xml file  and store it in the array using java

    Hi every one
    Can any one send me the java coding for traversing through XML file and get the data and store it in the array (SAX parser is prefered)
    its a urgent requirement . please help me
    Regards
    Arun

    i send it to ur mail id ,
    could you please send me a mail to [email protected]

  • Need help  traversing through files

    i have a folder with 99,999 xml files. i need to access each and everyone of these files to look for a certain value.my question is: is there any convenient way of traversing through these files?
    File xmlfile = new File("");
    File onefolder = new File("C:\\Documents and Settings\\drstempprojects\\Desktop\\Compiled\\NLB_Recam");
    String[] arroffiles = onefolder.list();
    for (int i=0;i<arroffiles.length;i++) {
        xmlfile = new File("...\\NLB_Recam\\" + arroffiles);
    this method is inefficient and takes a hell load of memory since we are creating an array of 99,999 strings and using each array slot only once. i'm pretty sure there are better solutions to this. suggestions pls anyone?thanks.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    i'm pretty sure there are better solutions to this. suggestions pls anyoneDon't store 100k files in the same directory.

  • Reading complex XML file in flex

    I have searched the web but found very primitive xml
    examples. I want to read a complex xml file which through
    httpservice .
    The xml file is ultimately going to become dataProvider of a
    tree. But I have no idea how to traverse this xml file. mentioned
    under are the xml file and HTTPService tag.
    I want to traverse it in the resultHandler function.
    Thank you very much

    Yes, as Greg says, use e4x.
    To do this you must set the HTTPService resultFormat="e4x";
    In you handler, do:
    var xmlResult= XML(event.result);
    trace(xmlResult.toXMLString());
    and away you go.
    Tracy

  • How can I convert the metadata tags on my mp4s to xml files so that they can be read in Windows Media Center?

    I have a library with almost 3000 movies and TV shows that I have fully tagged. However, I have decided to start using Windows Media Center and it does its metadata tagging through XML files.  I wanted to know if anyone could tell me if there was a way to extract the metadata from those mp4s and convert them to a format that WMC could read?  Thanks!!!!

    iTunes can make XML playlists so it might be all you need, I made a simple one file playlist and exported it from iTunes. The result is shown below. In principle I could delete the playlist and the entry from the library, as long as I don't delete the file, then later reimport the XML playlist file. I haven't tested this particular scenario, but I assume that iTunes will read all the properties as listed unless it can read some kind of tag from the file itself in which case the current value of the tag would take precedence.
    What I don't know is what media center would make of this file, or what its files look like, however assuming they have a similar structure that can be decoded then it should be possible to read data from the iTunes library and write out a text file that will make sense to media centre.
    Video Test.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>Major Version</key><integer>1</integer>
    <key>Minor Version</key><integer>1</integer>
    <key>Date</key><date>2013-09-26T23:30:26Z</date>
    <key>Application Version</key><string>11.1</string>
    <key>Features</key><integer>5</integer>
    <key>Show Content Ratings</key><true/>
    <key>Music Folder</key><string>file://localhost/E:/iTunes/iTunes%20Media/</string>
    <key>Library Persistent ID</key><string>CCF046191585EA85</string>
    <key>Tracks</key>
    <dict>
    <key>155170</key>
    <dict>
    <key>Track ID</key><integer>155170</integer>
    <key>Name</key><string>Abbott &#38; Costello: "Two Tens For A Five" &#38; "Who's On First"</string>
    <key>Artist</key><string>Abbott &#38; Costello</string>
    <key>Album Artist</key><string>Abbott &#38; Costello</string>
    <key>Album</key><string>Abbott &#38; Costello: "Two Tens For A Five" &#38; "Who's On First"</string>
    <key>Genre</key><string>Comedy Clip</string>
    <key>Kind</key><string>MPEG-4 video file</string>
    <key>Size</key><integer>110483524</integer>
    <key>Total Time</key><integer>532096</integer>
    <key>Year</key><integer>1950</integer>
    <key>Date Modified</key><date>2013-06-19T17:35:18Z</date>
    <key>Date Added</key><date>2012-12-01T17:30:57Z</date>
    <key>Bit Rate</key><integer>156</integer>
    <key>Comments</key><string>www.dvdvideosoft.com</string>
    <key>Artwork Count</key><integer>1</integer>
    <key>Persistent ID</key><string>5AF2C490D1E065CD</string>
    <key>Track Type</key><string>File</string>
    <key>Has Video</key><true/>
    <key>HD</key><false/>
    <key>Video Width</key><integer>1136</integer>
    <key>Video Height</key><integer>640</integer>
    <key>Location</key><string>file://localhost/E:/iTunes/iTunes%20Media/Home%20Vide os/Abbott%20&#38;%20Costello_%20_Two%20Tens%20for%20a%20Five_%20&#38;%20_Who's%2 0on%20First_.mp4</string>
    <key>File Folder Count</key><integer>3</integer>
    <key>Library Folder Count</key><integer>1</integer>
    </dict>
    </dict>
    <key>Playlists</key>
    <array>
    <dict>
    <key>Name</key><string>Video Test</string>
    <key>Playlist ID</key><integer>1930541</integer>
    <key>Playlist Persistent ID</key><string>30BF2769C94F7F29</string>
    <key>All Items</key><true/>
    <key>Playlist Items</key>
    <array>
    <dict>
    <key>Track ID</key><integer>155170</integer>
    </dict>
    </array>
    </dict>
    </array>
    </dict>
    </plist>
    Such files are easier to interpret if opened with Notepad++.
    tt2

  • JAXB duplicates database records in the output XML file

    I am trying to export a database through XML file using JAXB. But i get an XML file having my records with the @XMLElement name i gave it (SMS_Database) and also another one following it with <list/> as the RootElement name. I don't know where it's coming from. Here is the code:
    import java.io.*;
    import java.sql.*;
    import java.util.ArrayList;
    import javax.xml.bind.*;
    public class Parse2Xml {
      static final String XMLBASE = "./SMS_Database.xml";
      static ArrayList<Intermed> dataList = new ArrayList<Intermed>();
      static Connection con = null;
      static PreparedStatement ps = null;
      static ResultSet rs = null;
      public static void main(String[] args) throws JAXBException, IOException {
            con = getConnection();
            try{
              ps = con.prepareStatement("SELECT * FROM SMS_Log");
              rs = ps.executeQuery();
              while (rs.next()) {
                  dataList.add(getData(rs));
              rs.close();
              ps.close();
              con.close();
            } catch (SQLException ex) {
                ex.printStackTrace();
            DataStore SMS_Database = new DataStore();
            SMS_Database.setList(dataList);
            JAXBContext context = JAXBContext.newInstance(DataStore.class);
         Marshaller m = context.createMarshaller();
         m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
         Writer w = null;
         try {
              w = new FileWriter(XMLBASE);
              m.marshal(SMS_Database, w);
         } finally {
              try {
                   w.close();
              } catch (Exception e) {
        static Connection getConnection(){
            String sqlURL = "jdbc:mysql://localhost:3306/SMSDB";
            String username = "SUNNYBEN";
            String password = "drowssap";
            try {
                try {
                    Class.forName("com.mysql.jdbc.Driver").newInstance();
                } catch (InstantiationException ex) {
                    ex.printStackTrace();
                } catch (IllegalAccessException ex) {
                    ex.printStackTrace();
            } catch (ClassNotFoundException ex) {
                ex.printStackTrace();
            try {
                con = DriverManager.getConnection(sqlURL, username, password);
            } catch (SQLException ex) {
               ex.printStackTrace();
            return con;
        static Intermed getData(ResultSet rs) throws SQLException {
                Intermed mediator = new Intermed();
                mediator.setSms_id(rs.getString("sms_id"));
                mediator.setSender_id(rs.getString("sender_id"));
                mediator.setMessage(rs.getString("message"));
                mediator.setPhone_no(rs.getString("phone_no"));
                mediator.setDate_sent(rs.getString("date_sent"));
                mediator.setSchedule_date(rs.getString("schedule_date"));
                mediator.setUsername(rs.getString("username"));
                mediator.setResponse(rs.getString("response"));
                return mediator;
    import java.util.ArrayList;
    import javax.xml.bind.annotation.XmlElement;
    import javax.xml.bind.annotation.XmlRootElement;
    @XmlRootElement(namespace = "SMS_Database")
    class DataStore {
        @XmlElement(name = "SMS_Log")
        ArrayList<Intermed> dataList = new ArrayList<Intermed>();
        public ArrayList<Intermed> getList() {
            return dataList;
        public void setList(ArrayList<Intermed> dataList) {
            this.dataList = dataList;
    import javax.xml.bind.annotation.*;
    @XmlRootElement(name = "SMS_Log")
    @XmlType(propOrder = {"sms_id", "sender_id", "message", "phone_no", "date_sent", "schedule_date", "username", "response"})
    public class Intermed {
        private String sms_id;
        private String sender_id;
        private String message;
        private String phone_no;
        private String date_sent;
        private String schedule_date;
        private String username;
        private String response;
        public String getSms_id() {
            return sms_id;
        public void setSms_id(String sms_id) {
            this.sms_id = sms_id;
        public String getSender_id() {
            return sender_id;
        public void setSender_id(String sender_id) {
            this.sender_id = sender_id;
        public String getMessage() {
            return message;
        public void setMessage(String message) {
            this.message = message;
        public String getPhone_no() {
            return phone_no;
        public void setPhone_no(String phone_no) {
            this.phone_no = phone_no;
        public String getDate_sent() {
            return date_sent;
        public void setDate_sent(String date_sent) {
            this.date_sent = date_sent;
        public String getSchedule_date() {
            return schedule_date;
        public void setSchedule_date(String schedule_date) {
            this.schedule_date = schedule_date;
        public String getUsername() {
            return username;
        public void setUsername(String username) {
            this.username = username;
        public String getResponse() {
            return response;
        public void setResponse(String response) {
            this.response = response;
    }

    Dear All
    my requirement is to generate an xml file which looks similar to
    <?xml version="1.0" encoding="UTF-8"?>
    <?TestLine?>
    <test_mt>
    <field1>123</field1>
    <field2>234</field2>
    </test_mt>
    how to add <?TestLine?>  tag?
    Hi shabrasish and rajashekar
    i am new to java and xslt mapping can you guide me  or give me links which are similar to my requirement how to proceed with this kind of mapping
    thanks
    uday

  • How to send a request and get a response through xml

    How to send a request and get a response through xml files?

    This is the code that works for me. Hope you find it useful.
         public static String sendHttpGetRequest(String endpoint, String requestParameters){
              String result = null;
              // Send a GET request to the servlet
              try{
                   // Send data
                   String urlStr = endpoint;
                   if (requestParameters != null && requestParameters.length () > 0){
                        urlStr += "?" + requestParameters;
                   URL url = new URL(urlStr);
                   HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                   conn.setRequestProperty("Accept", "application/xml");
                   // Get the response
                   BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                   StringBuffer sb = new StringBuffer();
                   String line;
                   while ((line = rd.readLine()) != null){
                        sb.append(line);
                   rd.close();
                   result = sb.toString();
              } catch (Exception e){
                   e.printStackTrace();
              return result;
         }

  • Can I send an XML file to the server instead of just URL?

    I have installed the XML demos on my machine. I am using Oracle 8i. All the demos talks about getting URL and Parameter from the HTML Page, instead of this I want to send my XML file from Java Applet to server. Then do all the searching as is going on right now in the demos. After this I want to send another XML file back from server to client applet.
    Client ----->XMLFILE------>SERVER
    Client<-----XMLFILE<------SERVER
    Do we have any DEMO which shows that how to send request through XML file instead of
    "http://MachineName:Port/XSQL/DEMO/emp.xsql?find=A".
    I know that we are not using Java Applets in the demos but I will interact this file with applet, it's not a problem.
    I would appreciate if anyone who is really knowlegeable about these demos can answer my question.
    Thanks,
    Raza
    null

    http://forum.java.sun.com/thread.jspa?threadID=5158333
    http://forum.java.sun.com/thread.jspa?threadID=5158705
    Crossposting is lame.

  • XML File Travesing Help

    Iteration using Recursive Function
    Thanks a lot :)

    Not sure if it's the best you can get but QAD:
    var my_xml:XML =
    <cities>
    <city name="London">
    <city name="Manchester">
    <city name="Cairo">
    </city>
    <city name="Hawai">
    </city>
    </city>
    <city name="New York">
    <city name="Mexico City">
    </city>
    <city name="Tokyo">
    </city>
    </city>
    </city>
    </cities>;
    traceCities( my_xml.city[0] );
    function traceCities( xml:XML ):void
    trace( xml.@name );
    if ( xml.children() )
    for each( var node in xml.children() )
    traceCities( node );
    manofspirit wrote:
    > Iteration using Recursive Function
    > Thanks a lot :)
    >
    > Hello All
    > I have tried a lot to traverse this xml file using
    recursive function,
    > but vain
    > Im sure you guys will help me out
    >
    > recursive function shuold iterate and trace name filed
    as following
    >
    > london
    > manchester
    > cairo
    > hawai
    > newyork
    > maxico city
    > tokyo
    >
    >
    > XML File
    >
    >
    > <city name="London">
    > <city name="Manchester">
    > <city name="Cairo">
    > </city>
    > <city name="Hawai">
    > </city>
    > </city>
    > <city name="New York">
    > <city name="Mexico City">
    > </city>
    > <city name="Tokyo">
    > </city>
    > </city>
    > </city>
    >

Maybe you are looking for

  • How to set the frame size?

    Hi, Can some one show me how to set the frame size in this program? History: I have created a window and added a button but its to small. So I want to increase the size of the frame to at least 600X400 pixel. private static void showGUI() {         /

  • Imported photos from removable drive and only show on that drive

    I was attemping to copy all my photos to my laptop using PSE8. Some how instead of having my catalogue on C drive I have it on the removable drive. So the files won't import to C drive cause it says I already have them they don't show in the organize

  • Connect JavaFx(Applets) to J2EE - best practice & browser session

    Hi there, I’m new to JavaFX and Applet programming but highly interested. What I don’t get at the moment is how you connect the locally executed code of the applet to your system running on a server (J2EE). Of course there seem to be different ways b

  • Setting in point changes out point and vice verse

    I'm working on a motion graphics project in After Effects. Setting in and out points is fine but my After Effects is acting strange all of the sudden. It allows me to set an in point for a layer but once I set an out point it sets the in point back t

  • Transaction launcher issue in IC Web..

    Hi all, I have assigned the "CL_CRM_IC_ABOXSAMPLE_LEAD_PRO"  class in the Launch transaction. But in the output, it is displaying that in display mode, even i could not be able search the lead transactions(PCUI transactions). for my userid "SAP_PCC_I