Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp

Chris Ernst

Ranch Hand
+ Follow
since Oct 28, 2015
Chris likes ...
Java MySQL Database Netbeans IDE
Düsseldorf - Germany
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
2
Received in last 30 days
0
Total given
14
Given in last 30 days
6
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Chris Ernst

There are only tabs inside no CR or NL, but thanks for the hint tim

I have see it with the snippet from Campbell that there only tabs inside.

And it works now and I am very happy
1 week ago
I'll make it like this


Now I have only to handle the double tabs in front of the xml element, but I think its OK when the tabs will be removed, cause I hope that no special char is inside .
Bit in the case if one or more is inside it have to remove and the format is only for the programmers eyes to read it clear and it looks great

Reading line by line will omit all the \r and \n sequences


I don't create some of this only the tabs

and again a big lovely THANK YOU

Now I make some bench test how fast it is
1 week ago
Thank you!
I'll try it all right now...
I create the XML file with a program (it's an export from a database) to used it for an import in Apache Solr (and when a control char is in the file it sends me an error)
The main problem in my case is, it must be fast. The file is written in a temp folder and after clean up it will send to the right destination.
The other problem is, that we can't see maybe the chars (the most problem was that the char 31 was set in the text).

Please explain what you mean about the whole file being full of control characters


It can be in all "string" areas

What sort of characters? How many?


I don't know so I want to replace them all

1 week ago
hey there,

I need your help.
in my XML file could be some invisible control character: 0x00–0x1F and 0x7F–0x9F.
The XML file is like this:


maybe there some whitespaces, empty rows or tabs (till three in a row like this > \t\t\t <)
It comes from the XML generator...
I need a solution to replace all the control chars. For this I wrote this:


So far so good, but now I have to add each char to the array
Then I'll tryed with this one private final String patternString = "[\\x{00}-\\x{1F}]"; wich I found on https://stackoverflow.com/questions/26897810/using-java-regexes-to-match-a-range-of-unicode-code-points-outside-the-bmp-it?rq=1
But when I replace the match with patternString and remove the foreach loop, is the result that the hole document is full of control chars
On https://www.regular-expressions.info/unicode.html I found the \p{Cc} pattern wich is the same result...

Why? What is my mistake?

Cheers
Chris
1 week ago
I don t know...  the json file is *.js.gz and so bad nested that I chose the xml file...
I gone now the easy way, I kill this line

for those how want to know how to do

see at StackOverflow

Tim and Paul Thanks !
Hey Paul,

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...
Hey Folks,

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
run:
C:\tmp\XML\13thstreet.de_2017-12-19.xml
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?

Cheers

Chris
Dam it works

I don't ne the printText method.

Thanks anyway yeah

at this time I haven't try your last post... but her is the code

what I want is to store selected (the part from the element) in my database and for me is it equal if its null or filled up with data...

I have make toString() to get any result.

When I try it with the item(0).getTextContent, it goes in the first node and then runs in the catch with null like this

Current Element :Episode
id : 4712380
EpisodeName : Blood Rush: Part One
EpisodeNumber : 2
Language : de
Overview :
SeasonNumber : 0
lastupdated : 1391991457
seasonid : 488842
Catch-Block null

I have try XML Read and it worked but I cant select item for item

maybe I have a node in my brain I don't know

And the way to store the data from the file in the database is equal ...
so, I have tryed diffrend versions and this is my output...

Current Element :Episode
id : com.sun.org.apache.xerces.internal.dom.DeepNodeListImpl@c856c98
EpisodeName : com.sun.org.apache.xerces.internal.dom.DeepNodeListImpl@6b7760e9
EpisodeNumber : com.sun.org.apache.xerces.internal.dom.DeepNodeListImpl@82a53b0
Language : com.sun.org.apache.xerces.internal.dom.DeepNodeListImpl@446dbe9e
Overview : com.sun.org.apache.xerces.internal.dom.DeepNodeListImpl@632bfb27
SeasonNumber : com.sun.org.apache.xerces.internal.dom.DeepNodeListImpl@338bbf83
lastupdated : com.sun.org.apache.xerces.internal.dom.DeepNodeListImpl@6966dd91
seasonid : com.sun.org.apache.xerces.internal.dom.DeepNodeListImpl@40d6076d
showid : com.sun.org.apache.xerces.internal.dom.DeepNodeListImpl@7c983e93


Its only for test output...
ahhhh now the coin is falling

Thank you Carey and Paul I'll try it later at home and say you what happen

Cheers
Ok, thanks Paul

so my goal is, to write the data to an MySQL database and the sout is only a demo output to see what happen...

I have try the part from Carey (thank you for the fast response by the way)

but I get the same null

what have I done?


and call the method

If there an other better or easyer way to put the data into a database...