Unable to parse xml file

public class DOMEcho1 {
     static Document document;
     static String FILE_NAME = "slideSample01.xml";
     public static void main(String[] args) {
          DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
          Node node = null;
          try{
               DocumentBuilder builder = factory.newDocumentBuilder();
               document = builder.parse(new File(FILE_NAME));
               node = document.getParentNode();
          catch(SAXException e) {
          catch(ParserConfigurationException e) {
          catch(IOException e) {
}the XML file:
<?xml version='1.0' encoding='utf-8'?>
<!-- A SAMPLE set of slides -->
<slideshow
title="Sample Slide Show"
date="Date of publication"
author="Yours Truly"
>
<!-- TITLE SLIDE -->
<slide type="all">
<title>Wake up to WonderWidgets!</title>
</slide>
<!-- OVERVIEW -->
<slide type="all">
<title>Overview</title>
<item>Why <em>WonderWidgets</em> are great</item>
<item/>
<item>Who <em>buys</em> WonderWidgets</item>
</slide>
</slideshow>
I was unable to parse this xml file properly. When I called the method "getParentNode" it returns me a null value.
Anyone out there please guide me how to parse this xml file or advice me on the additional tasks I need to perform before I can start parsing.
Your advices will be greatly appreciated, thanks!

The documentation for getParent Node says:
All nodes, except Attr, Document, DocumentFragment, Entity, and Notation may have a parent.
I think what you want is getDocumentElement to get the root element (slideshow in your case).
Dave Patterson

Similar Messages

  • Error message "Unable to parse opf file: container.xml"

    The Message I get is
    ERROR ITMS-9000: "Unable to parse opf file: container.xml" at Book (MZItmspBookPackage)
    I have made the book in iBooks author- the previous version was fine, apple requested I "fix" it landscape mode. Since then... No Joy.

    Yep, i just did it again. The entire scroll-bar widget, complete with formatted text, graphics, etc., pasted itself nicely in another book. Two different files, the same widget.
    I use the scroll-bar widgets for most of my texts. (I have audio buttons on the side, and the scripts are within the widget, to the side). My only text is within widgets, and text boxes, naturally. 
    I am following your recommendation: cleaning files, etc. I am remaking the book anew. I need to convince the EPUB bot or whatever that my file looks and works nicely on all my devices. You would expect an error message when previewing the book: 'Hey Amigo, your file is flawed, stop working on it, and get back to the drawing board." Should be able to try again next Monday.

  • PO 7.4 RESTAdapter issue : Unable to parse XML message payload

    Dear experts,
    We are implementing the scenario Exposing a function module as Restful service with the PO RESTAdapter that's avaiable in PO 7.4 SP09 as described in the blog written by Ivo:
    PI REST Adapter – Exposing a function module as RESTful service
    When we test the scenario to processing messages the adapter reports the error message:
    Error while sending message to module processor: senderChannel '589b39c9b91c3ae99040d9addc6a818b': Catching exception calling messaging system: Unable to parse XML message payload to extract operation for receiver determinationorg.xml.sax.SAXParseException: Premature end of file.
    Anyone an idea or solution direction?
    Thanks in advance.
    Cheers, Luc

    Hi YRV isa,
    Issue solved by Ivo Kulms
    "Either you use a Dummy Interface in the IFlow for the adapter or you have to specify on the Operation Determination Tab which XI Operation / Interface should be used. The table on the tab allows to specify different interface name depending on the internal variables. In the variable columns add for example the REST operation, by entering "operation", in the expression column "GET" or "POST" or "*" and in the operation/namespace columns the XI operation / interface you want to reference.
    The variable "operation" has to be in curly brackets, so that it gets evaluated. So the entry should look like "{operation}" ( or like "{service}" if you want to map the XI operation by REST service name)"
    Kind regards, Luc

  • EhP1 - Unable to create XML file in Solman

    Hi all,
    I need some assistance
    I am trying to upgrade our XI system to EhP1 - SP04. I use Maintenance Optimizer in our Solution Manager (SAP EHP 1 for SAP Solution Manager 7.0) to select the necessary files for my upgrade. The XI system has been set up in SMSY an given a Logical Component. Also, added to the Solution Landscape. I use the SAPehpi-installer to upgrade XI.
    However, when I get to section three, I am supposed to provide the SMSDXML.xml file. This file is not created by our Solution Manager for some reason. The file, as I understand it, is supposed to be generated automatically during Maintenance Optimizer. But when I check the EPS and EPS/in folder of our solman, the file is not to be found. I have also checked the parameter DIR_EPS_ROOT in RZ11. It is correct. The authorization has been set to full on group Everyone, just to check if that could be the problem, but with no luck.
    When I use transaction /n/tmwflow/mopz_stack i am able to view the XML file (I assume that it is the correct file), but any attempt to copy the text displayed, and to save it as an XML-file has not resulted in any success.
    The only thing I have to go on, is a warning displayed in Maintenance Optimizer, stating: "Warning - No SLM configured in system - <SID>. Every document etc, Iu2019ve read sais that one can use Software Lifecycle Manager as an alternative to Download Basket. I havenu2019t seen SLM listed as a prereq, so I donu2019t believe that this could be the reason why the XML-file is not generated.
    Is there some setup/configuration Iu2019ve missed?
    Any help will be much appreciated!
    Best Regards,
    Stian
    Notes checked:
    1134872 FAQ for stack Delta Files
    1022704 Upgrade phase EHP_INCLUSION and SPSTACK_REQUEST
    1277035 Solution Manager: EHP4 product data missing

    I downloaded the SPSTab.xml from SMP, but it didnt work. It gave an error: "The selected configuration file ("C:EHP1SPSTab.xml") is not usable. Reason: "Stackfile not found""
    I have used the dockument in the link you provided as a basis for my upgrade. So I still need this to work in order to upgrade my XI Netweaver 7.0 to Enhancement Package 1...
    In the document you provided:
    Section 3 SAP Solution Manager
    3.1 Support Package Level of SAP Solution Manager (Check - Mine is EHP1)
    3.2 System Landscape (SMSY) of SAP Solution Manager (Check - as stated above in opening post)
    3.3 SAP Solution Manager Maintenance Optimizer (Check)
    3.4 SAP Solution Manager Troubleshooting: (Check)
    3.4.4 No Stack Configuration File is generated: This is the core of my problem... I have read the notes listed, and run the IMG activity under Maintenance Optimizer, as per note 1134872. I get an warning stating "SAP ChaRM auto-configuration warnings" This could be the source of the problem, but in the thread Re: Message no. IMG_FASTCONF028  in Charm SolManiac says that it is nothing to worry about.
    So to summarise:
    I an still unable to generate XML file in Solman, and I am uable to get the XML downloaded from SMP to work with SAPehpi.
    BR
    Stian
    (EDIT: I am however not shure if the settings under SMSY etc are 100% correct, but in my mind, that should prevent Maintenance Optimizer from generating the XML file)
    Edited by: Stian Eiken on Jul 13, 2009 1:18 PM

  • I have a Nikon D600 and D800 and I shoot everything in Raw. I use Photoshop Elements 9 for processing but I have been unable to convert any RAW files to open in PSE. Says unable to parse the file. What does this mean and how do I fix it?

    I have a Nikon D600 and D800 and I shoot everything in Raw. I use Photoshop Elements 9 for processing but I have been unable to convert any RAW files to open in PSE. Says unable to parse the file. What does this mean and how do I fix it?

    Since pse 9 can only use up to camera raw 6.5 and the d600 needs at least 7.3 and the d800 needs at least 6.7, you can use the
    8.6 adobe dng converter to convert those files to dng copies, which then pse 9 should open.
    8.6 dng converter
    windows
    Adobe - Adobe Camera Raw and DNG Converter : For Windows : Adobe DNG Converter 8.6
    mac
    Adobe - Adobe Camera Raw and DNG Converter : For Macintosh : Adobe DNG Converter 8.6
    Note:
    If you have windows xp or vista or mac os x 10.6, then you'll need to use the 8.3 dng converter instead
    windows
    Adobe - Adobe Camera Raw and DNG Converter : For Windows : Adobe DNG Converter 8.3
    mac
    Adobe - Adobe Camera Raw and DNG Converter : For Macintosh : Adobe DNG Converter 8.3
    how to use the dng converter
    Camera Raw: How to use Adobe DNG Converter - YouTube
    more info on supported cameras and camera raw plugins required
    Camera Raw plug-in | Supported cameras
    Camera Raw-compatible Adobe applications

  • Error in retrieving and parsing XML File

    Hi Folks
    I am Working on People centric user interface, While i am custimizing a application in Business application Builder i am getting this error
    " Error in retrieving and parsing XML File "
    can any body look on this and give me the solution
    it will be rewarded
    Regards
    M.S.Kumar

    Hello,
    As mentionned by SAP_TECH, avoid to use the BAB.
    Go to CRMC_BLUEPRINT_C and use the different option in the menu to customize the field group, toolbar group, events, ...
    Use the PCUI cookbook to find your way.
    Regards,
    Fred

  • How to parse XML files from normal FTP Servers?

    I want to parse xml files from a normal FTP Servers , NOT the sap application severs itself. How can i do that?
    I know how to use the SAPFTP getting and putting files ,but I don't want to download and then parse it.
    Who knows how to parse it directly? I Just need to read the contents into a database.
    Thanks.

    I want to parse xml files from a normal FTP Servers , NOT the sap application severs itself. How can i do that?
    I know how to use the SAPFTP getting and putting files ,but I don't want to download and then parse it.
    Who knows how to parse it directly? I Just need to read the contents into a database.
    Thanks.

  • How to compare after parsing xml file

    Hi,
    following code, parse the input.xml file, counts how many nodes are there and writes the node name and its value on screen.
    1) i am having trouble writing only node name into another file instead of writing to screen.
    2) after parsing, i like to compare each node name with another .xsd file for existence.
    Please keep in mind that, input.xml is based on some other .xsd and after parsing i have comparing its tag with another .xsd
    Need you help guys.
    thanks
    * CompareTags.java
    import java.io.*;
    import org.w3c.dom.*;
    import org.xml.sax.*;
    import javax.xml.parsers.*;
    import javax.xml.transform.*;
    import javax.xml.transform.dom.*;
    import javax.xml.transform.stream.*;
    /** This class represents short example how to parse XML file,
    * get XML nodes values and its values.<br><br>
    * It implements method to save XML document to XML file too
    public class CompareTags {
    private final static String xmlFileName = "C:/input.xml";
         int totalelements = 0;
    /** Creates a new instance of ParseXMLFile */
    public CompareTags() {
    // parse XML file -> XML document will be build
    Document doc = parseFile(xmlFileName);
    // get root node of xml tree structure
    Node root = doc.getDocumentElement();
    // write node and its child nodes into System.out
    System.out.println("Statemend of XML document...");
    writeDocumentToOutput(root,0);
                   System.out.println("totalelements in xyz tag " + totalelements);
              System.out.println("... end of statement");
    /** Returns element value
    * @param elem element (it is XML tag)
    * @return Element value otherwise empty String
    public final static String getElementValue( Node elem ) {
    Node kid;
    if( elem != null){
    if (elem.hasChildNodes()){
    for( kid = elem.getFirstChild(); kid != null; kid = kid.getNextSibling() ){
    if( kid.getNodeType() == Node.TEXT_NODE ){
    return kid.getNodeValue();
    return "";
    private String getIndentSpaces(int indent) {
    StringBuffer buffer = new StringBuffer();
    for (int i = 0; i < indent; i++) {
    buffer.append(" ");
    return buffer.toString();
    /** Writes node and all child nodes into System.out
    * @param node XML node from from XML tree wrom which will output statement start
    * @param indent number of spaces used to indent output
    public void writeDocumentToOutput(Node node,int indent) {
    // get element name
    String nodeName = node.getNodeName();
    // get element value
    String nodeValue = getElementValue(node);
    // get attributes of element
    NamedNodeMap attributes = node.getAttributes();
    System.out.println(getIndentSpaces(indent) + "NodeName: " + nodeName + ", NodeValue: " + nodeValue);
    for (int i = 0; i < attributes.getLength(); i++) {
    Node attribute = attributes.item(i);
    System.out.println(getIndentSpaces(indent + 2) + "AttributeName: " + attribute.getNodeName() + ", attributeValue: " + attribute.getNodeValue());
    // write all child nodes recursively
    NodeList children = node.getChildNodes();
              //int totalelements = 0;
    for (int i = 0; i < children.getLength(); i++) {
    Node child = children.item(i);
                   //     System.out.println("child value.."+child);
    if (child.getNodeType() == Node.ELEMENT_NODE) {
    writeDocumentToOutput(child,indent + 2);
                             if(node.getNodeName() == "DATA"){
                             totalelements = totalelements+1;}
                        //System.out.println("totalelements in DATA tag " + totalelements);
    /** Parses XML file and returns XML document.
    * @param fileName XML file to parse
    * @return XML document or <B>null</B> if error occured
    public Document parseFile(String fileName) {
    System.out.println("Parsing XML file... " + fileName);
    DocumentBuilder docBuilder;
    Document doc = null;
    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    docBuilderFactory.setIgnoringElementContentWhitespace(true);
    try {
    docBuilder = docBuilderFactory.newDocumentBuilder();
    catch (ParserConfigurationException e) {
    System.out.println("Wrong parser configuration: " + e.getMessage());
    return null;
    File sourceFile = new File(fileName);
    try {
    doc = docBuilder.parse(sourceFile);
    catch (SAXException e) {
    System.out.println("Wrong XML file structure: " + e.getMessage());
    return null;
    catch (IOException e) {
    System.out.println("Could not read source file: " + e.getMessage());
    System.out.println("XML file parsed");
    return doc;
    /** Starts XML parsing example
    * @param args the command line arguments
    public static void main(String[] args) {
    new CompareTags();
    }

    hi,
    check out the following links
    Check this blog to extract from XML:
    /people/kamaljeet.kharbanda/blog/2005/09/16/xi-bi-integration
    http://help.sap.com/saphelp_nw04/helpdata/en/fe/65d03b3f34d172e10000000a11402f/frameset.htm
    Check thi link for Extract from any DB:
    http://help.sap.com/saphelp_nw04s/helpdata/en/58/54f9c1562d104c9465dabd816f3f24/content.htm
    regards
    harikrishna N

  • ERROR ITMS-9000: "Unable to parse opf file: content.opf" at Book (MZItmspBookPackage)

    Hello,
    Here an itunes producer error for my new ibook:
    ERROR ITMS-9000: "Unable to parse opf file: content.opf" at Book (MZItmspBookPackage)
    Any help?
    Best!

    https://discussions.apple.com/message/17782799#17782799
    I thinks this link will help solve your issues. It worked for mine.

  • ERROR ITMS-9000: "Unable to parse opf file: package.opf" at Book

    ERROR ITMS-9000: "Unable to parse opf file: package.opf" at Book
    No problem checking repeatedly check the opf file could not be found.
    Please help me.

    ERROR ITMS-9000: "Unable to parse opf file: package.opf" at Book
    No problem checking repeatedly check the opf file could not be found.
    Please help me!!!!
    Please help me!!!!
    Please help me!!!!
    Please help me!!!!
    Please help me!!!!

  • Uloading ebook using iProducer rec'd error: ERROR ITMS-9000: "Unable to parse nav file: toc.ncx" at Book. I don't understand and need help fixing it. Please Help

    Uloading ebook using iProducer rec'd error: ERROR ITMS-9000: "Unable to parse nav file: toc.ncx" at Book. I don't understand and need help fixing it. Please Help if you've the knowledge.
    Many Thanks

    Yep, i just did it again. The entire scroll-bar widget, complete with formatted text, graphics, etc., pasted itself nicely in another book. Two different files, the same widget.
    I use the scroll-bar widgets for most of my texts. (I have audio buttons on the side, and the scripts are within the widget, to the side). My only text is within widgets, and text boxes, naturally. 
    I am following your recommendation: cleaning files, etc. I am remaking the book anew. I need to convince the EPUB bot or whatever that my file looks and works nicely on all my devices. You would expect an error message when previewing the book: 'Hey Amigo, your file is flawed, stop working on it, and get back to the drawing board." Should be able to try again next Monday.

  • How to parse xml file in midlet

    Hi Guys,
    i wish to parse xml file and display it in my midlet. i found api's supporting xml parsing in j2se ie., in java.net or j2se 5.0. Can u please help me what package to use in midlet?
    how to parse xml info and display in midlet? Plz reply soon......Thanks in advance....

    i have exactly the same problem with KXml2, but using a j2me-polish netbeans project.
    i've tried to work around with similar ways like you, but none of them worked. now i've spent 3 days for solving this problem, i'm a bit disappointed :( what is wrong with setting the downloaded kxml2 jar path in libraries&resources?
    screenshot

  • Parse XML files

    Hi
    Anyone know about support for parsing XML files in LabVIEW?
    (I mean specific XML support, I'm familiar with LabVIEWs file functions)
    regards
    Jan
    Sent via Deja.com http://www.deja.com/
    Before you buy.

    I assume you are referring to:
    http://www.savarese.org/oro/software/OROMatcher1.1.html
    Have you considered asking Savarese?
    Peace,
    Cameron Purdy
    Tangosol, Inc.
    http://www.tangosol.com
    +1.617.623.5782
    WebLogic Consulting Available
    "Laurent Mentek" <[email protected]> wrote in message
    news:[email protected]..
    Hi all,
    I'm started to develop with BEA WebLogic and I use ORACLE 8.1.6
    database.
    We need to map some XML tags as metadata in the database.
    Here is a concrete example with part of our XML files:
    XML files :
    <target>EDU</target>
    <question>
    <para>
    Please could you provide some references on nutritional status in
    the frail elderly?
    </para>
    </question>
    I use OROMatcher to parse xml files and it work fine.
    I can extract every element in line with success , but don't extract the
    value in <para> tag, for example.
    I don't no how to use the MULTILINE_MASK option and the ^ or $ to get
    this line.
    Anyone could give me an example of metadatas extaction using or no the
    MULTILINE_MASK option?
    Thanks a lot for your help.
    Laurent.

  • Parsing XML Files to ABAP

    Hello All,
    There is a requirement for parsing of XML files to ABAP.
    1.How do we pick an XML file from Application server and also from FTP server?
    2.After picking the XML file how to parse that XML file to process it to create material master?

    Hi,
    Ur scenario is File to R/3
    For creating material master ..i guess there is IDoc named MATMAS.
    U can make use of it and execute File to IDoc Scenario.
    link for File to IDoc--
    https://www.sdn.sap.com/irj/scn/wiki?path=/display/xi/fileToIDOC&
    U need to pick XML file from FTP server...No need to parse XML file...just create data type which represents ur xml file structure and map it to IDoc fields.
    regards,
    Manisha

  • How to stop parse XML file

    When using saxParser.parse(XMLfile, handler) to parse XML file, How to stop the parsing but not exit. I catched thread interrupted in startElement(), but can not stop it because it still go through all other startElement()s and endElement()s. Is there any method or class can stop parse XML?
    Appreciate your help!
    Edward

    Please look at the technote:
    http://access1.sun.com/technotes/01185.html
    Hope this helps.
    Michelle Cope
    Sun Microsystems.

Maybe you are looking for

  • Dynamically Add Report Parameters & Get Row Count

    In out Portal reports, we are inserting records into our own logging tables at the beginning of the report and updating the record at the end of the report. Currently, the sequential key has been added as a parameter so that we can access it through-

  • Lots of problems with os X mountain Lion...

    programs don't react ( safari, mail, itunes, iphoto...) problems shutting down my iMac , have to restart several times a day

  • How to create a Subtype?

    Hi All, I want to know the steps required to create the Subtypes for my Infotype as i need to create some extra feilds also in the already existing infotype? Thanks Regards, Nidhi

  • Adobe downloaded to multiple drives please help Thanks

    I purchased adobe web premium a couple of months ago. When I downloaded this program and I did a custom install to go onto another drive. With my computer I have several hard drives with multiple drives on them. I wanted this to go all onto my G driv

  • Formatting Output Based on Data in TVARVC

    Hi Guys In the below program I need to highlight lines of output where the plant complies to the rules green and those that do not in red in a variant called check plant. Here are the values. S    0000 I    EQ   1000 S    0001 I    EQ   3000 S    000