Hi,
Here is a sample xml file and expected output.
I need to extract the element/tag name (not value) and xpath (sample output.txt).
But the main problem is I put here one simple xml file where I can clearly see the number of elements, but in real time I have a xml file which have over 500 elements, so is there any option to find the elements automatically and retrive the xpath.
Thanx for the suggestion raj.
Appritiate your help.
But I don't need the element value, you can see my expected output there is a " " (space) between element name and xpath (so that i can differentiate with element name and xpath) but not the element value, otherwise its fine.
thanx again
Ya raj ..thanks a lot ... now the output looks same as per i requierd.
just suggest me one thing .. should i save that code sample.ksh with starting a header line #!/usr/bin/ksh ??
if so then in the time of execution should i write like this :
ksh sample.ksh sample.xml
---------- Post updated at 12:54 PM ---------- Previous update was at 12:47 PM ----------
yes .. its working as i wrote starting with header line #!/usr/bin/ksh
yes raj .. thanx for ur extreme help ....
this is exactly what i need ...
this one is perfect for one xml file ..but in our scenario we have a share folder where almost 10000 xml will be stored every month.
there i can create one param file contains all xml file names with extension.
now my question is ... is it possible to pass that param file into ur above code which will give output as one .txt file contains all element name along with xpath as ur output was.
there might be 200 common elements in all xml files and rest of all are might be new....so we have have to make one superset of all elements and have to put down in one test file along with the xpath.
note : actually we are building sas mapping script to load all xml to oracle db, previously we did manual copy paset work for all xml and it took 10 days to cover almost all elements
kindly suggest, do we can load all xml element data to oracle db using shell script?
Here i attached 5 xml files for your reference. but in our share-path more than 10000 this type of xml file will be comming in every month.
we have to store all data into a oracle table (this can be more than one table if required).
at very begining we dont have any fixed oracle table, we have created three table as per elements we found in xml file.
Through SAS we successfully load all xml files into different oracle tables, but during that SAS script writing we have to write all elements name along with xpath manually and that was a truely boring work for all files.
by shell script we made one param file containing all names of xml files and passed that param file to our SAS code. SAS read all xml one by one and insert all data into oracle tables.
Now in coming week probably we will not be able to access SAS and we have to pull all xml data from that xml files in share-path into oracle table by one shell script.
now you suggest me is this possible or not.... check the xml files(attached) and give me some idea.
atleast help me on your post#8
using your code i can get required output.
i have attached 5 xml files on post#11
i can use param file like fileNames.txt(attached here) and passing this file into your code how i can generate one output.txt which contains all elements and xpath(like your output) of all 5 files together.
Advance thanx for your kindful help.
--Bithun
i just want to pass the fileNames.txt as a parameter file which contains 5 xml file-names.
just pass the file name one by one into your code and append the result in output.txt
otherwise you suggest how i can extract all elements and xpath of all xml files by one script.
---------- Post updated at 01:17 PM ---------- Previous update was at 01:16 PM ----------
in post#11 i attached 5 XML files for your reference..
Thank you Raj,
if you get time kindly run your above code with my 5 xml files (attached in post#11) and txt file as parameter (attached in post#13).
when i run txt file through your last code i got many types of output there, where some output is matching with my expected result and some is totally difference. i guess there need to be a small modification in your code to get the proper result from that 5 xml files.