I want to run a c++ program to process a lot of data from different xml files an
ID: 659155 • Letter: I
Question
I want to run a c++ program to process a lot of data from different xml files and output results. I run the program once per file and potentially have around 50 different files.
The trouble is each xml file has different naming convention for the nodes, for example:
A.xml
<entry>
<id><![CDATA[9]]></id>
<description><![CDATA[Dolce 27 Speed]]></description>
</entry>
B.xml
<item>
<uuiid><![CDATA[9]]></uuid>
<content><![CDATA[Dolce 27 Speed]]></content>
</item>
What is the appropriate way to define these mappings, so when I run the program the software knows what data is in what tags, so I can store the id, description etc together no matter what the input tags are.
Ideas I have so far are:
A) Start the program with flags (in the real program there will be 10 mappings so could get messy), I.e ./main --id uuid --description content
B) Put them in a map and refer to that at start up (any suggestions on how to do the map would be great), I.e ./main --map example1
C) None of the above
Explanation / Answer
I would think that the best thing to do would be to employ a tool like Xalan or Xtrans or any other XSLT processor to implement an intermediate XML transformation step, so that your software needs to know only one naming convention.
The ability to perform such transformations is one of the major reasons why XML was invented in the first place.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.