This week's book giveaways are in the Cloud and AI/ML forums. We're giving away four copies each of Cloud Native Patterns and Natural Language Processing and have the authors on-line! See this thread and this one for details.
I want to read a xml file(insert the data to a Database...) see below
To read this file I have this code:
and after run this code I will get this result
XML Reader C:\tmp\XML\xmltv.dtd (Das System kann die angegebene Datei nicht finden) <- It means: The System can't found this file
BUILD SUCCESSFUL (total time: 0 seconds)
what should I can do to read this file or to delete this line with the doctype?
Chris Ernst wrote:what should I can do to read this file or to delete this line with the doctype?
You could use a text editor to remove the !DOCTYPE line from your XML document. On the other hand there is quite likely a reason for that line being there, so maybe it would be preferable to find that DTD file and put a copy of it in the same directory as the XML document.
Most XML parsers I've worked with are validating by default and will get very annoyed if they cannot validate the XML.
There are several solutions, depending on what parser is being used.
1. Rip out the DOCTYPE by brute force prior to parsing it
2. Switch off validation (if your XML parser supports it)
3. Put stuff in your parsing code that dummies up the effect of the DOCTYPE.
4. Alter the DOCTYPE to be more complete (reference the official doctype's URL). A good system will cache this, a not-so-good one will fetch the DTD every time, experience latency delays and fail if the URL goes offline.
Additional note 1: the Java XML Document facility allows plugging in an XML parser (it doesn't do the actual parsing itself), The default one is SAX.
Additional note 2: I recommend using OS-neutral syntax when coding filename paths in Java. That is: new File("C:/tmp/XML/13thstreet.de_2017-12-19.xml") as an example.
Not only does exploying practices like this make your code more portable (I used to develop on a Windows desktop for deployment to Solaris production servers), note that you don't need to escape backslashes, thus avoiding the annoyances that getting the wrong number of backslashes can cause.
When it comes to destroying a civilization, gas chambers cannot hold a candle to echo chambers.
Chris Ernst wrote:yes that should be the easyest way, but (I forgot to told you) that I download the files from a server 7 files for each TV Broadcaster...
Perhaps you could parse the documents directly from the URL on the server; it's possible that the DTD would then be in the correct location relative to the document's URL and then the parser would be happy. But it's also possible that the DTD wouldn't be there.