Win a copy of Python Continuous Integration and Delivery this week in the Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

Output  RSS feed

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, i am having trouble with my output as i cannot get it to display as i am meant to.

This is the output that i need to achieve:

This is my output:

How i achieved the headings tags title with columns:

As you can see i tried to add the multimedia title etc but when i do that, i get the output:

I need to display the titles/columns like the first image demonstrates but not exactly sure how? It just prints them on top of eachother.

Another question:

Inside my text file that im reading from i have listed them as:

It displays the number 6,5,4,4 on top of them when it displays the output? How do i stop this. demonstrated:

Would it have something to do with initializing these?

How do you initialize them as you read through the tags file? Any help would be HIGHLY appreciated!!

Code for entire program:

 
Master Rancher
Posts: 1161
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As you can see... Like the first image... Something went wrong when uploading your images, we can't see them.
If you use img tags you can only use images that are saved online, otherwise you have to add them as an attachement.
Anyways have a look at how to format a string
 
Michael Connolly
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Daniel Demesmaecker wrote:As you can see... Like the first image... Something went wrong when uploading your images, we can't see them.
If you use img tags you can only use images that are saved online, otherwise you have to add them as an attachement.
Anyways have a look at how to format a string



Does it work if you right click  and open in a new tab?
 
Ranch Hand
Posts: 99
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rather explain in words what is your expected outcome and what the program is printing instead of using images.
 
Marshal
Posts: 63383
205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Daniel Demesmaecker wrote:. . . have a look at how to format a string

I am afraid I can see problems with that tutorial; maybe you should add it to your list of tutorials to avoid.
 
Michael Connolly
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Joseph Mokenela wrote:Rather explain in words what is your expected outcome and what the program is printing instead of using images.



Sorry, what? The images sums it up much cleaner and easier, surely?
 
Rancher
Posts: 3926
45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not if your set up does not download images from most sources.



Obviously the tab settings may not match what you have.
 
Campbell Ritchie
Marshal
Posts: 63383
205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Michael Connolly wrote:. . . The images sums it up much cleaner and easier, surely?

The images do not show up.
 
Michael Connolly
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to print:
Tag Usage Count           Used On Line(s)
=== =========== ===============

<h1 1                  11
<h2 4                  13, 14, 15, 17
<h3 2                  18, 20
<h4 2                  19, 21

Multimedia Tags:

Tag Usage Count Used On Line(s)
=== =========== ===============

<img 1 12
<iframe 1 16

Hyperlink and Head Tags:

Tag Usage Count Used On Line(s)
=== =========== ===============

<a 4 13, 14, 15, 17
<title 1 04
<meta 4 06, 07, 08
<link 1 05

Other Tags:

<!DOCTYPE - found on line 01
<html - found on line 02
<head - found on line 03
<body - found on line 10

END OF ANALYSIS


but mine is printing:

Headings Tags:

Tag Usage Count Used On Line(s)
== =========== ===============
Multimedia Tags:

Tag Usage Count Used On Line(s)
== =========== ===============
Hyperlink and Head Tags:

Tag Usage Count           Used On Line(s)
== =========== ===============
6 1               16,
<h1 1               11,
<h2 6               13, 14, 15, 17, 19, 20,
<h3 1               18,
<h4 1               21,
<img 1       12,
<iframe 1       16,
4 2               21, 21,
<a 4               13, 14, 15, 17,
<title 1       4,
<meta 3       6, 7, 8,
<link 1               5,
4 2               21, 21,
<!DOCTYPE 1       1,
<html 1       2,
<head 1       3,
<body 1       10,



Also, as you can see it's printing 6,4,4 on top of the tags on the left column.

Here is whats inside the text file:

23
6
<h1
<h2
<h3
<h4
<h5
<h6
5
<img
<video
<audio
<object
<iframe
4
<a
<title
<meta
<link
4
<!DOCTYPE
<html
<head
<body

I add these variables but not sure where to initialise them as you read through the tags file.
int numHeadingsTags;
int numMultimediaTags;
int numHyperlinkAndHeaderTags;



I hope that's a better explanation than the images?
 
Campbell Ritchie
Marshal
Posts: 63383
205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please explain what those numbers are supposed to mean.
 
Michael Connolly
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Please explain what those numbers are supposed to mean.



Yeah, proably a good idea lol i was limited to what i could post in the first post i think i was meant to explain in the second, my bad.

Anyways, as you can see from the menu. Number 1 is to load the seo tag definitions... then 2 is to display them. Which displays: (below the code)


Display the seo tag definitions:
Loading SEO Tags Definitions
6
<h1
<h2
<h3
<h4
<h5
<h6
5
<img
<video
<audio
<object
<iframe
4
<a
<title
<meta
<link
4
<!DOCTYPE
<html
<head
<body

They get this from a seotags.txt file.

Option 3 is to load and anaylse an HTML file (ranges.html) Which looks like this:



From the above, it will anaylse and count the number of different html tags, the usage count and what lines they're on etc. However, my output is displaying as

Headings Tags:

Tag Usage Count Used On Line(s)
== =========== ===============
Multimedia Tags:

Tag Usage Count Used On Line(s)
== =========== ===============
Hyperlink and Head Tags:

Tag Usage Count Used On Line(s)
== =========== ===============
6 1 16,
<h1 1 11,
<h2 6 13, 14, 15, 17, 19, 20,
<h3 1 18,
<h4 1 21,
<img 1 12,
<iframe 1 16,
4 2 21, 21,
<a 4 13, 14, 15, 17,
<title 1 4,
<meta 3 6, 7, 8,
<link 1 5,
4 2 21, 21,
<!DOCTYPE 1 1,
<html 1 2,
<head 1 3,
<body 1 10,

INSTEAD OF

Headings Tags:

Tag Usage Count Used On Line(s)
=== =========== ===============

<h1 1 11
<h2 4 13, 14, 15, 17
<h3 2 18, 20
<h4 2 19, 21

Multimedia Tags:

Tag Usage Count Used On Line(s)
=== =========== ===============

<img 1 12
<iframe 1 16

Hyperlink and Head Tags:

Tag Usage Count Used On Line(s)
=== =========== ===============

<a 4 13, 14, 15, 17
<title 1 04
<meta 4 06, 07, 08
<link 1 05

Other Tags:

<!DOCTYPE - found on line 01
<html - found on line 02
<head - found on line 03
<body - found on line 10

END OF ANALYSIS

 
Michael Connolly
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems whatever way its displaying here is different from what im putting in this box...

I need it to display like this:




This is how mine is displaying:

 
Michael Connolly
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure what's going on putting the words on here its messing up the message box so i attached the images.
output-4.PNG
[Thumbnail for output-4.PNG]
My output is displaying as follows but in the image below is how i need it to display
output.PNG
[Thumbnail for output.PNG]
 
Dave Tolls
Rancher
Posts: 3926
45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In lines 175-183 you print out all the section headers.
Only then do you loop through your data to print out the tags.
Presumably what you want is to print out a header and then iterate over the array associated with that header, then print the next header, and so on.
 
Michael Connolly
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Dave Tolls wrote:In lines 175-183 you print out all the section headers.
Only then do you loop through your data to print out the tags.
Presumably what you want is to print out a header and then iterate over the array associated with that header, then print the next header, and so on.



I sort of get what you mean but not totally with you. Would you be able to provide an example?

Thanks
 
Michael Connolly
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I spent the last few hours trying to work it out.

I was trying by giving the arrays int[] numHeadingsTags = {1,2,3,4}; etc

then going down to the lines you told me to
")

then doing a for loop for like for

                                               
But im running into a lot of errors. I am really struggling to wrap my head around how to do this.
 
Dave Tolls
Rancher
Posts: 3926
45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looking again at the code above I'm not too sure you are actually splitting up the tags?
I can't tell all that easily.

My first suggestion is to, at the very least, get all that code in switch case you are having issues (3) with out into a seperate method.
Then break that method down into steps, each of which should be a seperate method.
That way you break the problem down into smaller parts.

So, from a quick look, I would have:
getFileName method, which covers 106 to 133 (though I would not open a FileScanner, since that chunk of code doesn't seem to do anything...just test whether the file exists using the Files.exists method).
parseFile method, covering 139 to 173.
displayResults method, covering 175 to 197.

I would write the output method first, since that defines what format you want the data to be in from the method that will parse the file.

I would possibly even break it down more, but the above should help you to focus on one part of the problem at a time.

 
Michael Connolly
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Dave Tolls wrote:Looking again at the code above I'm not too sure you are actually splitting up the tags?
I can't tell all that easily.

My first suggestion is to, at the very least, get all that code in switch case you are having issues (3) with out into a seperate method.
Then break that method down into steps, each of which should be a seperate method.
That way you break the problem down into smaller parts.

So, from a quick look, I would have:
getFileName method, which covers 106 to 133 (though I would not open a FileScanner, since that chunk of code doesn't seem to do anything...just test whether the file exists using the Files.exists method).
parseFile method, covering 139 to 173.
displayResults method, covering 175 to 197.

I would write the output method first, since that defines what format you want the data to be in from the method that will parse the file.

I would possibly even break it down more, but the above should help you to focus on one part of the problem at a time.



• You may not use any Java language (or library) parsing routines for this program

I am not allowed to use these.
 
Dave Tolls
Rancher
Posts: 3926
45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not suggesting you do.
I'm suggesting you break your code up into methods so it's easier to work with.

At the moment you have one great blob of code, which has a tendency to make someone looking at it think in terms of one huge problem, rather than lots of smaller problems.

So break the code down into smaller methods.
 
Sheriff
Posts: 5745
148
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Seems whatever way its displaying here is different from what im putting in this box...  


Try disabling HTML rendering when you want to post visible HTML.  It's the first checkbox beneath where you write your message.
 
I am not young enough to know everything. - Oscar Wilde This tiny ad thinks it knows more than Oscar:
Become a Java guru with IntelliJ IDEA
https://www.jetbrains.com/idea/
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!