-3

I have an xml file from which I have to find the duplicates.

My XML file looks like this

Reference XML

I want to find the count of all element names

I tried the following code to first take all the names into a text file:

Script I have wrote till now

But this throws an error saying Can't find LibXML.

Borodin
  • 126,100
  • 9
  • 70
  • 144
S6633d
  • 101
  • 2
  • 10
  • 6
    you can directly write your code in the question. – Arijit Panda Jun 28 '16 at 12:57
  • Looks linke you have to install a nativ library called libXML. Which OS do you use? – Jens Jun 28 '16 at 12:59
  • you can take all the element in an array and then follow : **http://stackoverflow.com/questions/3011888/whats-the-most-efficient-way-to-check-for-duplicates-in-an-array-of-data-using** link – Arijit Panda Jun 28 '16 at 13:02
  • 2
    Instead of adding image for reference, write your code and XML fine in the question. It would be helpful for people who want help you. – serenesat Jun 28 '16 at 13:06
  • where is the title element in you sample file sorry image? – ssr1012 Jun 28 '16 at 13:09
  • 2
    Please don't post a screenshot of your code. Just post your code. Ideally self contained as an [mcve] – Sobrique Jun 28 '16 at 13:13
  • 1
    Please read and become familiar with Stack Overflow, and what sort of questions are acceptable. You should also read [*How do I ask a good question?*](http://stackoverflow.com/questions/how-to-ask). Images are occasionally useful, for instance to show the layout of a graphical display, but in general data and code should be posted as *text* so that we can copy it to experiment and reproduce the problem ourselves – Borodin Jun 28 '16 at 13:20
  • I don't think the error is `Can't find LibXML`. Please post the *full error message*. It will include a source file path and a line number. – Borodin Jun 28 '16 at 13:23
  • Is this homework? Counting the occurrences of element names isn't generally a useful thing to do. You are welcome to ask about homework problems, but the nature of the answers should change to help you to learn – Borodin Jun 28 '16 at 13:24
  • is there any way to do this without using a libXML parser ? – S6633d Jun 29 '16 at 04:57
  • @sureshbalaji it's a bad idea to avoid using a proper parser. What issues do you have with the answer I gave below? – Dr.Avalanche Jun 29 '16 at 09:25

2 Answers2

0

You probably need to install the XML::LibXML module

Borodin
  • 126,100
  • 9
  • 70
  • 144
0

You have to install the module XML::LibXML, from the command line:

cpan XML::LibXML

Before doing so you need the non perl dependancies this module requires detailed in the README:

Prior to installation you MUST have installed the libxml2 library. You can get the latest libxml2 version from....

Dr.Avalanche
  • 1,944
  • 2
  • 28
  • 37