Importing XML into Java.  Help needed Please!!!

Hi,
I have downloaded j2sdk1.4.1_05 and want to configure it to import XML files into a DOM in Java. I am having trouble doing this and need help. I read that version 1.4 support JAXP 1.1 but I am having trouble finding the JAXP-api.jar file. It says to put all the other Jar files into a folder and leave the JAXP-api.jar.
Could you please tell me how to set up Java so that I can import an XML file. I also downloaded JAXP 1.2. But there seems to be no installer.
Thanx John

You can learn about reading xml in java by reading the J2EE tutorial at
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/
Here is sample program to read XML file into a DOM taken from this tutorial
(http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JAXPXSLT4.html)
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.w3c.dom.Document;
import org.w3c.dom.DOMException;
import java.io.*;
public class TransformationApp
  static Document document;
  public static void main(String argv[])
    if (argv.length != 1) {
      System.err.println (
        "Usage: java TransformationApp filename");
      System.exit (1);
    DocumentBuilderFactory factory =
      DocumentBuilderFactory.newInstance();
    //factory.setNamespaceAware(true);
    //factory.setValidating(true);
    try {
      File f = new File(argv[0]);
      DocumentBuilder builder =
        factory.newDocumentBuilder();
      document = builder.parse(f);
    } catch (SAXParseException spe) {
      // Error generated by the parser
      System.out.println("\n** Parsing error"
        + ", line " + spe.getLineNumber()
        + ", uri " + spe.getSystemId());
      System.out.println("  " + spe.getMessage() );
      // Use the contained exception, if any
      Exception x = spe;
      if (spe.getException() != null)
        x = spe.getException();
      x.printStackTrace();
    } catch (SAXException sxe) {
      // Error generated by this application
      // (or a parser-initialization error)
      Exception x = sxe;
      if (sxe.getException() != null)
        x = sxe.getException();
      x.printStackTrace();
    } catch (ParserConfigurationException pce) {
      // Parser with specified options can't be built
      pce.printStackTrace();
    } catch (IOException ioe) {
      // I/O error
      ioe.printStackTrace();
  } // main
} If you have java 1.4 sdk installed everything should compile and run. Separate
JAXP package is nor required - JAXP is included in rt.jar in java-home-directory/jre/lib.

Similar Messages

  • Java help needed(PLEASE)

    I have a Question for all you gifted people:
    I am designing a sort of quiz which takes questions and three possible answers from a database(which also holds the real answer).It prints these on the dos screen and I then have a System.in statement which allows the user to enter his or her answer (eg A,B,C or 1,2,3). I need a way of adding up the score at the end!!I was thinking of storing there answers in an array and compairing there answer to my correct answer in the database and if it is the same add 1 and if it not the same add 0???
    How would i write the System.in answers into an array and add them up???
    These are my thoughts on how to do this i would love to hear yours!! And also a help with writing the code for the above system of scoreing would be GREATLY appriciated!!
    thanks everyone,
    james.

    As mathuoa pointed out, since you already display the 3 possible answers to the user, get them into an array and display them on the screen. Then, as the user enters an answer, compare them with the three answers and if it is correct, update the score variable as such. If you want the history of answers that the user has given, then u will have to use a Vector/List/some such collection object to hold the user's answers.
    java.util.Vector answers = new java.util.Vector();
    answers.add(usersAnswer1);
    answers.add(usersAnswer2);
    Then, to get the entries,
    for(Enumeration e = answers.elements(); e.hasMoreElements();)
    System.out.println(e.nextElement());
    //Do something with the answer.
    This is one possible way of getting the answers from the user!

  • Howto import XML into Excel table ?

    Hi,
    I asked this before in the Excel forums but received the suggestion that I ask here instead.  The question precis : How to ungrey the "Append new data to existing XML lists" checkbox so I can select it when importing XML data into an Excel
    spreadsheet.
    I have a local server which provides data in XML form and need to import successive reloads of the XML page into successive lines in an Excel spreadsheet.  I found the Excel help page entitled "How to use XML in Excel 2003" at http://office.microsoft.com/en-gb/excel-help/how-to-use-xml-in-excel-2003-HA001101964.aspx?CTT=1&origin=EC001022986
    which was useful in so far as permitting me to import the data using the XML Source task pane and mapping the elements I need from the XML source to columns in the spreadsheet.
    In order to append successive lines from the XML source page, as I understand it from the link I quoted,  I need to change the XML Map properties to "Append new data to existing XML lists".  However this checkbox is greyed out in the
    XML Map properties dialog box so I can't select it.
    Any ideas how I can achieve my aims here ?
    Thanks in advance,
    Mike

    Hi Mike,
    Thank you for contacting Office IT Pro General Discussions Services. 
    From your description, I understand that you tried to import XML into Excel table. You selected “Use the XML Source
    task pane” when opening the XML file, then you tried to check the option in the
    Map Properties window: "Append new data to existing XML lists". 
    However, this option is grayed out. If there is any misunderstanding, please feel free to let me know.
    I have checked the issue on my side but could not reproduce this issue. I suggest download the sample XML file as suggested on the page and test the
    issue again:
    http://www.microsoft.com/downloads/details.aspx?FamilyId=B4BD3283-AD0B-408D-9CE7-AB9C3537BBBB&displaylang=en
    If the problem does not occur with the sample XML file, this issue might occur as there are some problems with the XML you were using.
    If the problem also occurs in with the sample XML file, this issue might be related to some third-party software conflicts. I suggest checking this
    issue by starting Excel in the safe mode.
    Start the Office program in safe mode
    ==============
    1.      
    Click Start, point to All Programs, and then point to
    Microsoft Office.
    2.       
    Press and hold the CTRL key, and then click
    Microsoft Excel.
    If the problem does not occur in the safe mode, this issue might be related to some third-party add-ins in the Excel program, we can try to disable
    them. Normally, you could do the following to disable the conflict add-ins in your Excel program:
    Disable add-ins
    Click
    Tools > Options > 
    Add-in, click Go button in the Manage:
    Com-in Add.
    Check if there are any add-ins,
    clear the checkbox to disable them.
    Close the Office program and
    restart it.
    Add one check back each time to the list of Add-In,
    restart the Office program, and repeat the above procedure. Once the issue reappears again, we can determine which add-in causes this problem and then disable it.
    Please take your time to try the suggestions and let me know the results at your earliest convenience. If anything is unclear or if there is anything
    I can do for you, please feel free to let me know.
    Best Regards,
    Sally Tang

  • Convert MBox into XML into Java Objects

    Hello all,
    this is a general question, i dont know weather there is such libs or not.
    However, please tell me what you know.
    i want to program a java application for searching purpose in Mbox.
    i thought its possible and easier to try to convert the emails from the MBox into XML files, and from these create java objects when i need or even convert the XML into html for viewing.
    Any suggestions are welcome.
    Also antoher solutions are greate.
    thanks in advance!
    Sako.

    I don't know what this MBox you speak of is - I assume it's not the thing I use to hook upa guitar to GarageBand. Maybe you mean it as a generic term for mailbox? The easiest solution (to my mind) would be to use a Java API provided by whatever MBox is. If there is no such thing, then if you get XML-formatted version of the messages I suppose writing code to parse the XML into Java Objects would be a good option if you wanted to do further manipulation of them, but if all you want to do is display them as HTML in a browser then just use XSLT to transform them.
    Good Luck
    Lee

  • Can't Figure Out How To Import XML into a Table?

    HELP!
    I've been using InDesign for several years now... but everything Ive ever done has been basic one off layout concepts.
    I am working on a website for a musical theater actress and for her resume, Id like to make a PDF which lists in table format the show, theatre and role she had for each job.
    I could do this manually... but Id really like to learn how to just reuse the same XML data that I have for her website and import it into InDesign.
    I have looked at Adobe's help file, I have scoured the internet, and I still can't figure it out... I have done like the adobe support file says... and I cant seem to get the values I create in her resume xml file to show up in a table I create in InDesign.
    I even tried to simplify it for the learning process and did something as basic as an XML file that has 5 colors... couldnt even get that working.
    So could someone explain it to me like Im a 5 year old... how to take a XML file, import it, place it in a table and have the data actually show up in the table.
    thanks,
    brian

    Are you sure you want to use XML with tables for this? No doubt importing XML into tables is useful for some specialized tasks, such as importing formatting information inside the XML itself, but for most of the familiar tasks that XML excels at, tables are neither necessary nor useful.
    In my (limited) experience, if the XML elements are well-differentiated, by which I mean different types of data have their own distinctive tags, then the special powers of XML can be exploited more fully using the more familiar tagged text, nested tags etc. in ordinary text frames using paragraph breaks, tab characters, etc. to achieve a suitably "tabular" finished appearance.
    If you must import XML into tables, I recommend Adobe's own PDF "Adobe InDesign CS3 and XML: A Technical Reference" availabe here:
    http://www.adobe.com/designcenter/indesign/articles/indcs3ip_xmlrules.pdf
    It sounds very daunting -- the words "technical reference" make me shudder -- but actually it's very readable and not very technical at all. Some nice pics and everything!
    Jeremy

  • Import XML into Essbase?

    Is it possible to import XML into Essbase or are we limited to flat files or Excel files? If XML is an option, can someone point me to some documentation?
    Thx!

    Essbase supports the following types of data sources only
    Text files (flat files) from text backups or external sources
    SQL data sources
    Essbase export files (export files do not need a rules file to load)
    Microsoft Excel files with the .XLS extension, Version 4.0 and higher
    Microsoft Excel files, Version 5.0 and higher (loaded only as client artifacts or files in the file system)
    Spreadsheet audit log files

  • How to import XML into SQL Table

    Dear all,
    There are a lot of books about exporting data into XML format.
    Actually, how to use XML Documents? Sorry I am new that I ask such a question.
    What i think may be exchange or save data using xml. If so, How to import into MS SQL table? Do it need to do any mapping?
    Appreciate for your hints

    Are you sure you want to use XML with tables for this? No doubt importing XML into tables is useful for some specialized tasks, such as importing formatting information inside the XML itself, but for most of the familiar tasks that XML excels at, tables are neither necessary nor useful.
    In my (limited) experience, if the XML elements are well-differentiated, by which I mean different types of data have their own distinctive tags, then the special powers of XML can be exploited more fully using the more familiar tagged text, nested tags etc. in ordinary text frames using paragraph breaks, tab characters, etc. to achieve a suitably "tabular" finished appearance.
    If you must import XML into tables, I recommend Adobe's own PDF "Adobe InDesign CS3 and XML: A Technical Reference" availabe here:
    http://www.adobe.com/designcenter/indesign/articles/indcs3ip_xmlrules.pdf
    It sounds very daunting -- the words "technical reference" make me shudder -- but actually it's very readable and not very technical at all. Some nice pics and everything!
    Jeremy

  • Help needed please.. how do I remove my credit card from itunes? just discovered over $450 of charges when I looked at my email... Kids had no clue they were using our money and not their gift cards

    Help needed please.... I just discovered over $450 charges to my credit card from Itunes. The kids had no idea they were using our credit card and not their itunes gift cards and 4 year old just clicks on anything! I didnt save my credit card details so am a bit miffed at this... I cant find anywhere in itunes to remove it. Edit.. but not remove. Editing does not remove it.. HELP

    To Contact iTunes Customer Service and request assistance
    Use this Link  >  Apple  Support  iTunes Store  Contact
    Accepted forms of payment  >  http://support.apple.com/kb/HT5552
    Changing Account Information  >  http://support.apple.com/kb/HT1918

  • Help needed please, with Iphone stuck with apple picture and progress bar after software update attempted

    Help needed please, everytime I try to update the software version on my iphone it comes up with a message saying it could not be completed and is now frozen with the apple picture and progress bar on it. Do I unplug it and hope the macbook pro sees it again, I also stupidly did not back up before starting the download which I realise I will have to go back to the previous back up. This keeps happening, everytime I do this type of update, I'm starting to think I should just give up on updating my software on the Iphone. I thought it was happening because I was using a window based computer to do the updates, this time I used my Macbook Pro. Please somebody help

    ljm17 wrote:
    ...This keeps happening, everytime I do this type of update, I...
    Then you should know what you need to do... If you don't remember...
    See Here  >  http://support.apple.com/kb/HT1808

  • Is it possible to import xml into Adobe Muse to populate content similar to InDesign?

    Is it possible to import xml into Adobe Muse to populate content similar to InDesign?

    The only way I see this would be possible is through using JS that you can insert using the Object -> Insert HTML option, you may grab the XML to HTML code from here - http://www.w3schools.com/xml/xml_to_html.asp
    In order to test this out, simply download the sample XML file from the following location - http://www.w3schools.com/xml/cd_catalog.xml and save it somewhere locally. Now add this file to your Muse project using File -> Add Files for Upload option, it would then appear within the Assets panel.
    Add the code to your page and update the path referencing the file cd_catalog.xml to assets/cd_catalog.xml. Now on previewing the page in browser, you should see the populated HTML from the XML.
    Thanks,
    Vinayak

  • Having a problem importing xml into an indesign template.

    I am having a problem importing xml into an indesign template. The xml data is there and will populate the columns on the document but I am having problems matching styles, removing data that should not be mapped and importing repeated same fields but differnet data.
    Message me if this is something you can do quickly for a fee.

    Also you can check the following link
    [Reporting|http://devlibrary.businessobjects.com/BusinessObjectsXIR2/en/devsuite.htm]
    Regards,
    Tej

  • I recently had to restore my Iphone 4s and ever since I cannot double click the home button whilst the phone is locked and change my music. The controls come up and I can adjust the volume but I cannot change the songs. Help needed please!!

    I recently had to restore my Iphone 4s and ever since I cannot double click the home button whilst the phone is locked and change my music. The controls come up and I can adjust the volume but I cannot change the songs. Help needed please!!

    Have you guys been able to activate your iphone yet? I bought an iphone 4s from eBay and it worked fine, but the previous user had left some data on it, so last night I used the "erased all content and settings" to restore it to factory setting so I can start fresh and restore my backup. But now I'm stuck at the activation screen (I get the same "the activation server is temporarily unavailable")  and can't get it to activate, even if I use my old deactivated AT&T sim card (I'm on straighttalk now).
    I might try activating it with an active AT&T sim card from my fiancee's phone when she gets home, so I'll let you know how that works outs.
    If it's true that the server is down; anyone know when it will be back up again? Thanks in advance.
    iPhone 4s iOS 5.1.1 (9B206)
    Carrier AT&T 12.0
    Modem Firmware 2.0.12

  • Unable to import xml into my CS4 project

    Hi folks,
    I am trying to embed a 3rd party flash component into my current flash project.  As a stand alone, the component works fine but when I try and import the xml file for the component into my current flash project library, the message I get:
    " one or more files were not imported because there were problems reading them"!!!
    I have tried importing the xml file into another dummy cs4 project on another machine and again no success, so I believe there are elements within the xml file that will not work with cs4.  Below is the xml file code.  I would appreciate if anyone can spot anything wrong with this file as to why it wont import into flash.  Even try and import it yourself and see what I mean.
    Hope someone can help.
    Regards
    Volterony22
    <?xml version="1.0" encoding="UTF-8"?>
    <!--
    There are 9 positions available :
    1. TL: top-left
    2. TC: top-center
    3. TR: top-right
    4. ML: middle-left
    5. MC: middle-center
    6. MR: middle-right
    7. BL: bottom-left
    8. BC: bottom-center
    9. BR: bottom-right
    If you set randomizePositions to true, it will overwrite the values you pass for each item
    startZoom: the zoom value to start with
    endZoon: the zoom value to end with
    transitionTime: the time for the slide to reach from property A to property B
    slideShowTime: the time the slide stays on screen
    disablePauseButton: it needs to be set to true if you want to have links on the slideshow
    -->
    <!--
    NOTE: The transition time must be higher than the slideshow time for each item! (make sure the difference is at least alphaTime value)
      The reason is so the zoom effect doesn't end before the transition does.
    -->
    <kenburns width = "1000" height = "348"
    backgroundColor = "0x000000"
    backgroundTransparency = "0"
    startWith = "1"
    randomSlideshow = "true"
    loop = "true"
    randomizeImagePosition = "false"
    alphaTime = "2"
    textX = "10"
    textY = "10"
    overColor = "0x000000"
    overAlpha = "20"
    disablePauseButton = "true">
    <!--
    <item>
    <title><![CDATA[<font size="16" color="#ffffff">Sand beach in the morning</font>]]></title>
    <path>content/images/image1.jpg</path>
    <link></link>
    <target>_blank</target>
    <transitionTime>12</transitionTime>
    <slideShowTime>8</slideShowTime>
    <startZoom>80</startZoom>
    <endZoom>100</endZoom>
    <startPosition>MC</startPosition>
    <endPosition>MC</endPosition>
    </item>
    <item>
    <title></title>
    <path>content/images/image2.jpg</path>
    <link></link>
    <target>_blank</target>
    <transitionTime>25</transitionTime>
    <slideShowTime>22</slideShowTime>
    <startZoom>100</startZoom>
    <endZoom>55</endZoom>
    <startPosition>MC</startPosition>
    <endPosition>MC</endPosition>
    </item>
    <item>
    <title><![CDATA[<font size="18" color="#ffffff">Waves and wind</font>]]></title>
    <path>content/images/image3.jpg</path>
    <link></link>
    <target>_blank</target>
    <transitionTime>27</transitionTime>
    <slideShowTime>20</slideShowTime>
    <startZoom>70</startZoom>
    <endZoom>100</endZoom>
    <startPosition>TC</startPosition>
    <endPosition>BC</endPosition>
    </item>
    <item>
    <title><![CDATA[<font size="18" color="#224F91">No words needed..</font>]]></title>
    <path>content/images/image4.jpg</path>
    <link></link>
    <target>_blank</target>
    <transitionTime>12</transitionTime>
    <slideShowTime>9</slideShowTime>
    <startZoom>80</startZoom>
    <endZoom>80</endZoom>
    <startPosition>BL</startPosition>
    <endPosition>TR</endPosition>
    </item>
    <item>
    <title></title>
    <path>content/images/image5.jpg</path>
    <link></link>
    <target>_blank</target>
    <transitionTime>35</transitionTime>
    <slideShowTime>32</slideShowTime>
    <startZoom>55</startZoom>
    <endZoom>100</endZoom>
    <startPosition>BC</startPosition>
    <endPosition>TC</endPosition>
    </item>
    -->
    <item>
    <title></title>
    <path>content/images/image6.jpg</path>
    <link>http://www.flabell.com</link>
    <target>_blank</target>
    <transitionTime>10</transitionTime>
    <slideShowTime>8</slideShowTime>
    <startZoom>40</startZoom>
    <endZoom>35</endZoom>
    <startPosition>ML</startPosition>
    <endPosition>MR</endPosition>
    </item>
    <item>
    <title></title>
    <path>content/images/image7.jpg</path>
    <link></link>
    <target>_blank</target>
    <transitionTime>20</transitionTime>
    <slideShowTime>8</slideShowTime>
    <startZoom>70</startZoom>
    <endZoom>55</endZoom>
    <startPosition>MR</startPosition>
    <endPosition>ML</endPosition>
    </item>
    <item>
    <title></title>
    <path>content/images/image3.jpg</path>
    <link></link>
    <target>_blank</target>
    <transitionTime>20</transitionTime>
    <slideShowTime>8</slideShowTime>
    <startZoom>50</startZoom>
    <endZoom>60</endZoom>
    <startPosition>ML</startPosition>
    <endPosition>MR</endPosition>
    </item>
    </kenburns>

    Hi there,
    Thank you for responding.  When I say component, I have purchased a flash component from a company called www.flabell.com.  When you buy the component, you get the as, swf, assest, images, fla etc etc. 
    My goal is to embed this component into a flash project that I am working on at the moment which involves importing the assets/resources from the flabell component folder into the library of my current flash project.
    My folder structure at the moment is that I have top level folder call project.  In this folder is my actual flash project folder and the flabell component folder.  So no the html that embeds my main swf is not in the same folder as my 3 party swf - they are in two different locations.  However should this be an issue if I am importing the xml into my main project library anyway?
    Hope this info shines more light.
    Regards
    volterony22

  • Program to import xml into mysql

    Hello, I am trying to find a program that will get the url of an xml page, and it will convert it into a mysql table. I have managed to find a couple of programs that do this kind of thing, such as Exult professional edition for MySqL and Navicat, but a) They are both trial versions and their full versions require payment and b) The Navicat program can convert from xml files that are saved inside the computer. But I need the program to get the url of the xml page, because I need the database to be updated when the xml page is updated. Can anyone help me with this please?Thank you very much!

    There are certain websites that provide XML feeds about some events that will occure in different places. I want to retrieve these XML pages from 3 different websites in order to create a jsf project. I want to input the information that these XML pages contain into a database because I want to create queries. the information is like this:
    <news groupName="news" type="group">
    &#8722;
         <news_name dataType="RawString" fieldName="news_name" href="http://www.epractice.eu/document/4506" originalElement="span" type="field">
    AT/DE: Administrations can network � wiki shows the way
    </news_name>
    &#8722;
         <news dataType="RawString" fieldName="news" originalElement="div" type="field">
    Efficiency & Effectiveness, Benchmarking, Interoperability and infrastructure, Open Source, eServices for Citizens
    </news>
    <loc dataType="RawString" fieldName="loc" originalElement="span" type="field">Austria, Germany</loc>
    &#8722;
         <news dataType="RawString" fieldName="news" originalElement="div" type="field">
    Using Web 2.0 and semantic technologies, the new Austrian-based platform documents best practice examples of co-operation between administrations at all levels of government. By the end of its first month, it had 53 project descriptions on-line,...
    </news>
    </news>

  • Psuedocode to java. help needed if poss

    i need to convert the following into java, but i am not sure how to output it..
    Roll a 12 sided die to choose a number between 1...12
    while the user has not made an incorrect guess
    ask the user if the next number will be higher or lower
    choose random number
    if users guess is correct
    increment count of correct guesses
    update the stored current number
    end if
    end while
    tell the user how many correct guesses there are
    any help would be greatful, i am a beginning so go easy!!!
    thanks alot
    stevie

    hey, sorry if i've caused a 'cross post', i am not too sure what it is but i hope i haven't done anything wrong! so far i am just trying to put a basic program together before building on it..
    import java.util.scanner;
    public class dice
    public static void main (String [] args)
    Scanner in = new Scanner(System.in);
    Random rnd = new Random();
    System.out.print("input a number between one and twelve")     int r =in.nextInt;
                   int r = rnd.nextInt(12) + 1;
              System.out.println(r);
    i know this has errors, but i was just hoping for a hint/clue for the basic program before researching more to build on it.. hope this code will help. reply when you can, thank you very much
    stevie

Maybe you are looking for

  • DRQ: Different default warehouse for Sales,Purchase and Production Process

    Hi Experts, In my recent Implementation Project I realised that there should be provision of capturing and using different default warehouse for Sales,Purchase and Production. For example in manufacturing company 1. Default ware house for Purchase pr

  • JMS beginner -Environment help

    I read the JMS tutorial on the sun's website. Still some of the concepts are not clear to me. I'm trying to understand JMS as analogous to JDBC. Can somebody answer the following questions 1) In JDBC paradigm, You have JDBC API, and a JDBC implementa

  • 1355 the spec domain could not be contacted 1355, other AD mess

    I've inherited a mess here.  What I have is an environment with 1) Windows Server 2003 Std (vm) 2) Server 2008 R2 (vm) running on a 2008 R2 Hyper V host.  Both servers were DC's.  The problem is that when pointing DNS to either DC, there would be all

  • Config Steps for LOP

    Hi, Request you to kindly forward me the config steps for LOP. Thanks & regardse Please take the search forum help before posting the  still if you not able to find will share you the issue

  • How to direct the Work Items in SBWP to different folders

    Hello All , Is there a possibility of having a rule on the SBWP , so that the work items coming in to the inbox can be placed in different folders based on some grouping . I see 4 kinds of grouping : Grouped according to task Grouped according to con