XML DOM error

XML DOM error

import org.w3c.dom.*;
import javax.xml.parsers.*;
import java.io.*;

public class DOMCountElement{
public static void main(String[] args) {
try {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter File name: ");
String xmlFile = bf.readLine();
File file = new File(xmlFile);
if (file.exists()){
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
// Create the builder and parse the file
Document doc = factory.newDocumentBuilder().parse(xmlFile);
System.out.print("Enter element name: ");
String element = bf.readLine();
NodeList nodes = doc.getElementsByTagName(element);
System.out.println("xml Document Contains " + nodes.getLength() + " elements.");
}
else{
System.out.print("File not found!");
}
}
catch (Exception ex) {
System.out.println(ex);
}
}
}

the above program "To Count XML Element" was copied from this website (roseindia.net) but im getting a error like this... "java.io.IOException: Server returned HTTP response code: 503 for URL: http://www.w3.org/TR/html4/strict.dtd" im using eclipse IDE.. please help me with this. Thank u
View Answers

February 9, 2010 at 2:59 PM

Hi Friend,

Here this code works fine.It seems that your code could not find the file that you have specified. Instead of input the file from command prompt check the code by specifying the file name in the code like:

String xmlFile = "C:\\data.xml";

If you got the error again,then send full error details.

Thanks









Related Tutorials/Questions & Answers:
XML DOM error - Java Beginners
XML DOM error  import org.w3c.dom.*; import javax.xml.parsers....("xml Document Contains " + nodes.getLength() + " elements."); } else...); } } } the above program "To Count XML Element" was copied from this website (roseindia.net
XML Error checker and locater (DOM)
XML Error checker and locater (DOM)   ... and locate (line and column number) an error in your XML document using the DOM APIs.  The XML document follows some rules to check its syntax. 
Advertisements
DOM - XML
DOM  Hi... I created an xml file through java by using DOM Now..I need to get the prompt for download when i clicked the button... I used downloadaction...for this But it didn't worked.. Its jus viewing the xml file
javascript dom error-message
javascript dom error-message  javascript dom error-message
DOM - XML
DOM  Hello.... I'm creating an xml file from java using DOM... from the database values... and saving it in a file But the created xml file..."),rs.getString("email")); } System.out.println("Xml File Created
DOM to SAX and SAX to DOM - XML
Java DOM to SAX and SAX to DOM  Simple API for XML and Document Object Model
Java-XML-DOM - XML
Java-XML-DOM  Hi! I need some help. I have to make java program that loads an xml file and from it builds DOM(later i will have to work with it - like using xpath in java find some value and replace it...). Since i'm new to java
dom to xml string
dom to xml string  Hi, I am writing a program in java that reads... have save the dom document into xml file. How to convert dom to xml string... for converting DOM object into string data. Please check the thread dom to xml
DOM to SAX and SAX to DOM - XML
DOM SAX Parser Java  What is the Difference between SAX and DOM parsers
XML DOM Tutorial
XML DOM Tutorial       W3C provides a standard called DOM (Document Object Model) for HTML & XML documents. DOM is also used as an interface for accessing and manipulating HTML & XML
Version of com.globalmentor>globalmentor-xml-dom-impl dependency
List of Version of com.globalmentor>globalmentor-xml-dom-impl dependency
deployment error - XML
getting the following error after i deployed my war file on tomcat.I suspecting my... web.xml entries to support spring and site mesh?? here is the error on my console and my web.xml ......... -------------------------------------- SEVERE: Error
XML error message: The reference to entity
XML error message: The reference to entity   XML error message: The reference to entity "ai" must end with the ';' delimiter. Im getting this error when i gotta edit my blogger template Please advice manjunath
Read Complex XML using DOM/SAX Parser.
Read Complex XML using DOM/SAX Parser.  I have a XML file which is having two types of Items. I want to extract all details of a type only. My XML goes something like this <Movie> <Bollywood> <Actor> Shah Rukh
Question about parsing XML document with DOM in JAVA.
Question about parsing XML document with DOM in JAVA.  Hi, I need to parse a XML file witch has info about classes. So i have for each class to have... it with multiple for loops, one iside the other but it doesnt work. My XML is this below
java code to create xml document from DOM object
java code to create xml document from DOM object  Hey! After knowing the way we can create DOM objects and add elements to it-> then displaying it on the console ;is there a way I can output the same in xml document
Maven Dependency globalmentor-xml-dom-impl >> 0.5.0
You should include the dependency code given in this page to add Maven Dependency of com.globalmentor >> globalmentor-xml-dom-impl version0.5.0 in your project
Error after restart server... - XML
Error after restart server...  Hi, Im using Oracle JDeveloper 10g and Oracle SQL database.. Yesterday, the server team said they want to restart... app run perfectly... i got this error when i try to run my app:- 10/05/14
XML Error Checking and Locating
XML Error Checking and Locating     ... in the XML document and error position.  Description of program:ADS_TO_REPLACE_1 The following program helps you in checking and locating an error in XML
DOM
DOM  package name for Document class?   Hi Friend, The package is known as dom api.ADS_TO_REPLACE_1 For more information, visit the following links: http://www.roseindia.net/xml/ http://www.roseindia.net/xml/dom
com.globalmentor - globalmentor-xml-dom-impl version 0.6.1 Maven dependency. How to use globalmentor-xml-dom-impl version 0.6.1 in pom.xml?
com.globalmentor  - Version 0.6.1 of globalmentor-xml-dom-impl Maven...-xml-dom-impl in pom.xml? How to use globalmentor-xml-dom-impl version 0.6.1... to use com.globalmentor  - Version 0.6.1 of globalmentor-xml-dom-impl
Maven Repository/Dependency: com.globalmentor | globalmentor-xml-dom-impl
Maven Repository/Dependency of Group ID com.globalmentor and Artifact ID globalmentor-xml-dom-impl. Latest version of com.globalmentor:globalmentor-xml-dom-impl dependencies. # Version Release Date
Getting Dom Tree Elements and their Corresponding XML Fragments
Getting Dom Tree Elements and their Corresponding XML Fragments... will learn to get the elements of a DOM tree and their corresponding XML... the DOM tree elements and their corresponding XML fragments are displayed
Java XML Parsing Using DOM
Java XML Parsing Using SAX To Parse XML document using SAX parser method you need to follow the following steps. Consider the following XML file Students.xmlADS_TO_REPLACE_1 <?xml version="1.0" encoding="UTF-8
Java DOM Tutorial
. ADS_TO_REPLACE_3 XML Error checker and locater (DOM) In this section... and their inter-relationships. The DOM is an interface that exposes an XML document as a tree... and using xml files using the standard SAX, DOM and XSLTs.   
org.camunda.spin - camunda-spin-dataformat-xml-dom version 1.5.4 Maven dependency. How to use camunda-spin-dataformat-xml-dom version 1.5.4 in pom.xml?
org.camunda.spin  - Version 1.5.4 of camunda-spin-dataformat-xml-dom... of camunda-spin-dataformat-xml-dom in pom.xml? How to use camunda-spin-dataformat-xml-dom...-dataformat-xml-dom in project by the help of adding the dependency in the pom.xml
DOM
DOM  hello, What is DOM?   hii,ADS_TO_REPLACE_1 DOM is stands for Document object Model. DOM is an interface-oriented Application Programming Interface. We can use it for navigation of the entire document
Reading xml file using dom parser in java with out using getelementby tag name
Reading xml file using dom parser in java with out using getelementby tag name  Hi, How to read the xml file using java with dom parser, but without...-Beginners/8384-java-with-xml-parsing.html but it is not reading attribute
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for globalmentor-xml-dom-impl version 0.6.4
for globalmentor-xml-dom-impl version 0.6.4. You can add these depency in your project to get com.globalmentor:globalmentor-xml-dom-impl:0.6.4 Java library in your project... for globalmentor-xml-dom-impl version 0.6.4 In this section have given
XML Parsing Error: mismatched tag. Expected: </br>. - JSP-Servlet
XML Parsing Error: mismatched tag. Expected: .  i had an error:"XML Parsing Error: mismatched tag. Expected: ." when uploading and writing them into an xml file. i use the jspBean to call the writeXML class. pls help me to solve
Maven Repository/Dependency: org.camunda.spin | camunda-spin-dataformat-xml-dom
Maven Repository/Dependency of Group ID org.camunda.spin and Artifact ID camunda-spin-dataformat-xml-dom. Latest version of org.camunda.spin:camunda-spin-dataformat-xml-dom dependencies. # Version Release
Maven dependency for com.globalmentor - globalmentor-xml-dom-impl version 0.6.6 is released. Learn to use globalmentor-xml-dom-impl version 0.6.6 in Maven based Java projects
of globalmentor-xml-dom-impl released The developers of   com.globalmentor - globalmentor-xml-dom-impl project have released the latest version of this library...-xml-dom-impl library is 0.6.6. Developer can use this version ( com.globalmentor
Maven dependency for com.globalmentor - globalmentor-xml-dom-impl version 0.6.4 is released. Learn to use globalmentor-xml-dom-impl version 0.6.4 in Maven based Java projects
of globalmentor-xml-dom-impl released The developers of   com.globalmentor - globalmentor-xml-dom-impl project have released the latest version of this library...-xml-dom-impl library is 0.6.4. Developer can use this version ( com.globalmentor
Maven dependency for com.globalmentor - globalmentor-xml-dom-impl version 0.6.5 is released. Learn to use globalmentor-xml-dom-impl version 0.6.5 in Maven based Java projects
of globalmentor-xml-dom-impl released The developers of   com.globalmentor - globalmentor-xml-dom-impl project have released the latest version of this library...-xml-dom-impl library is 0.6.5. Developer can use this version ( com.globalmentor
Maven dependency for org.camunda.spin - camunda-spin-dataformat-xml-dom version 1.14.4 is released. Learn to use camunda-spin-dataformat-xml-dom version 1.14.4 in Maven based Java projects
-spin-dataformat-xml-dom released The developers of   org.camunda.spin - camunda-spin-dataformat-xml-dom project have released the latest version... - camunda-spin-dataformat-xml-dom library is 1.14.4. Developer can use
Maven dependency for org.camunda.spin - camunda-spin-dataformat-xml-dom version 1.17.0 is released. Learn to use camunda-spin-dataformat-xml-dom version 1.17.0 in Maven based Java projects
-spin-dataformat-xml-dom released The developers of   org.camunda.spin - camunda-spin-dataformat-xml-dom project have released the latest version... - camunda-spin-dataformat-xml-dom library is 1.17.0. Developer can use
Maven dependency for org.camunda.spin - camunda-spin-dataformat-xml-dom version 1.18.0 is released. Learn to use camunda-spin-dataformat-xml-dom version 1.18.0 in Maven based Java projects
-spin-dataformat-xml-dom released The developers of   org.camunda.spin - camunda-spin-dataformat-xml-dom project have released the latest version... - camunda-spin-dataformat-xml-dom library is 1.18.0. Developer can use
Maven dependency for org.camunda.spin - camunda-spin-dataformat-xml-dom version 1.14.3 is released. Learn to use camunda-spin-dataformat-xml-dom version 1.14.3 in Maven based Java projects
-spin-dataformat-xml-dom released The developers of   org.camunda.spin - camunda-spin-dataformat-xml-dom project have released the latest version... - camunda-spin-dataformat-xml-dom library is 1.14.3. Developer can use
Maven dependency for org.camunda.spin - camunda-spin-dataformat-xml-dom version 1.14.2 is released. Learn to use camunda-spin-dataformat-xml-dom version 1.14.2 in Maven based Java projects
-spin-dataformat-xml-dom released The developers of   org.camunda.spin - camunda-spin-dataformat-xml-dom project have released the latest version... - camunda-spin-dataformat-xml-dom library is 1.14.2. Developer can use
Maven dependency for org.camunda.spin - camunda-spin-dataformat-xml-dom version 1.14.1 is released. Learn to use camunda-spin-dataformat-xml-dom version 1.14.1 in Maven based Java projects
-spin-dataformat-xml-dom released The developers of   org.camunda.spin - camunda-spin-dataformat-xml-dom project have released the latest version... - camunda-spin-dataformat-xml-dom library is 1.14.1. Developer can use
Maven dependency for org.camunda.spin - camunda-spin-dataformat-xml-dom version 1.14.0 is released. Learn to use camunda-spin-dataformat-xml-dom version 1.14.0 in Maven based Java projects
-spin-dataformat-xml-dom released The developers of   org.camunda.spin - camunda-spin-dataformat-xml-dom project have released the latest version... - camunda-spin-dataformat-xml-dom library is 1.14.0. Developer can use
Maven dependency for org.camunda.spin - camunda-spin-dataformat-xml-dom version 1.13.1 is released. Learn to use camunda-spin-dataformat-xml-dom version 1.13.1 in Maven based Java projects
-spin-dataformat-xml-dom released The developers of   org.camunda.spin - camunda-spin-dataformat-xml-dom project have released the latest version... - camunda-spin-dataformat-xml-dom library is 1.13.1. Developer can use
Maven dependency for org.camunda.spin - camunda-spin-dataformat-xml-dom version 1.11.5 is released. Learn to use camunda-spin-dataformat-xml-dom version 1.11.5 in Maven based Java projects
-spin-dataformat-xml-dom released The developers of   org.camunda.spin - camunda-spin-dataformat-xml-dom project have released the latest version... - camunda-spin-dataformat-xml-dom library is 1.11.5. Developer can use
Maven dependency for org.camunda.spin - camunda-spin-dataformat-xml-dom version 1.11.4 is released. Learn to use camunda-spin-dataformat-xml-dom version 1.11.4 in Maven based Java projects
-spin-dataformat-xml-dom released The developers of   org.camunda.spin - camunda-spin-dataformat-xml-dom project have released the latest version... - camunda-spin-dataformat-xml-dom library is 1.11.4. Developer can use
Maven dependency for org.camunda.spin - camunda-spin-dataformat-xml-dom version 1.16.0 is released. Learn to use camunda-spin-dataformat-xml-dom version 1.16.0 in Maven based Java projects
-spin-dataformat-xml-dom released The developers of   org.camunda.spin - camunda-spin-dataformat-xml-dom project have released the latest version... - camunda-spin-dataformat-xml-dom library is 1.16.0. Developer can use
Maven dependency for org.camunda.spin - camunda-spin-dataformat-xml-dom version 1.15.0 is released. Learn to use camunda-spin-dataformat-xml-dom version 1.15.0 in Maven based Java projects
-spin-dataformat-xml-dom released The developers of   org.camunda.spin - camunda-spin-dataformat-xml-dom project have released the latest version... - camunda-spin-dataformat-xml-dom library is 1.15.0. Developer can use
Maven dependency for org.camunda.spin - camunda-spin-dataformat-xml-dom version 1.11.3 is released. Learn to use camunda-spin-dataformat-xml-dom version 1.11.3 in Maven based Java projects
-spin-dataformat-xml-dom released The developers of   org.camunda.spin - camunda-spin-dataformat-xml-dom project have released the latest version... - camunda-spin-dataformat-xml-dom library is 1.11.3. Developer can use
Maven dependency for org.camunda.spin - camunda-spin-dataformat-xml-dom version 1.11.2 is released. Learn to use camunda-spin-dataformat-xml-dom version 1.11.2 in Maven based Java projects
-spin-dataformat-xml-dom released The developers of   org.camunda.spin - camunda-spin-dataformat-xml-dom project have released the latest version... - camunda-spin-dataformat-xml-dom library is 1.11.2. Developer can use
Maven dependency for org.camunda.spin - camunda-spin-dataformat-xml-dom version 1.10.5 is released. Learn to use camunda-spin-dataformat-xml-dom version 1.10.5 in Maven based Java projects
-spin-dataformat-xml-dom released The developers of   org.camunda.spin - camunda-spin-dataformat-xml-dom project have released the latest version... - camunda-spin-dataformat-xml-dom library is 1.10.5. Developer can use
Maven dependency for org.camunda.spin - camunda-spin-dataformat-xml-dom version 1.10.4 is released. Learn to use camunda-spin-dataformat-xml-dom version 1.10.4 in Maven based Java projects
-spin-dataformat-xml-dom released The developers of   org.camunda.spin - camunda-spin-dataformat-xml-dom project have released the latest version... - camunda-spin-dataformat-xml-dom library is 1.10.4. Developer can use

Ads