Introducing tags

  • 20
Read from the console the name of a file containing HTML. Example: Info about Leela Leela Turanga Supergirl The main method's first parameter is a tag name. For example, "span". Display all tags that match the speci
You can't complete this task, because you're not signed in.
Comments (9)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Nyerges Ferenc Level 23, Bükkábrány, Hungary
16 November 2020, 18:06
Unbelievable, I'm the 189th. I'll be honest - it took me two days to get the point and ~1.5 hours to implement the final version. My tip for those struggling with it: Watch the requirement example output very closely. You need to break and "expand" each tag in a recursive way from outside to inside - then continue parsing til lthe end.
klesk Level 28, Duisburg, Germany
24 April 2020, 08:15
Maybe for other persons, who struggle with this task, here are some inputs which helped me to solve this task. This first input is from Roman and was posted in one of the help threads. tag: a input:
<sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[1]</a></sup> <a
href="/wiki/">wiki<a href="1">2</a></a>
output:
<a href="#cite_note-1">[1]</a>
<ahref="/wiki/">wiki<a href="1">2</a></a>
<a href="1">2</a>
You will notice the missing space. THIS IS ON PURPOSE and NOT A FLAW. From the given Example, but with some changes. tag: tag input:
<tag>text1</tag>
<tag text2><tag>text3<tag>text4</tag></tag>text1</tag>
<tag
text2>text1</tag>
output:
<tag>text1</tag>
<tag text2><tag>text3<tag>text4</tag></tag>text1</tag>
<tag>text3<tag>text4</tag></tag>
<tag>text4</tag>
<tagtext2>text1</tag>
Again, the missing space is not a flaw.
3 June 2020, 14:53
This is a huge help! Thank you!
Skynet Level 31, USA
6 March 2020, 15:52
Hint: use Jsoup and this task becomes quite easy.
klesk Level 28, Duisburg, Germany
21 April 2020, 11:06
And there is no problem using an external library with the validation?
Skynet Level 31, USA
21 April 2020, 16:49
Not for this task it seems.
Seferi Level 22, United Federation of Planets
15 November 2020, 20:11
I'm getting the right output but still doesn't validate with Jsoup...
Diana Salvador Level 26, Sintra, Portugal
17 February 2020, 17:14
It took me more that 2 complete days to complete the task! Please don't give up guys! :)
Alexander Shtunder Level 41, San Francisco, USA
5 September 2019, 18:46
Hard task.. very hard