Sorry for the late reply. It took a while and help from some friends who have more knowledge also about this subject. He told me the same thing and gave me a short example of what is possible. With that example i was able to product the line below:
I was not aware that you could "backtrack" the tree and get the main info added to the product info. It most likely isn't the cleanest solution but at least it works great.
Quote:
Originally Posted by Chubler_XL
SDohmen, I don't generally thank people for posting questions.
However you've posted good example data and a clear and concise question with a reasonable attempt at solving it yourself. Also the tool your using is the right one for the job, so many XML parsing questions posted here want to use sed / grep / awk which will usually fail given a different XML layout.
Interesting to note that if you start from the parent level, which would have been my first inclination, you only get the first product under that parent:
Thank you for this. I always try my best to get as much as possible done myself. Only if i am really stuck i will post the question and even that is most likely days after i got stuck. I find it important to try and test myself although sometimes that is not possible. For each problem it is of course searching for the best solution and even though i dont fully understand xmlstarlet it gave me the best results for all the scripts i have used it on. I seen several attempts with sed etc but they where so confusing or gave me weird outputs (Its like opening a door with a hammer instead of the key ) that i wanted to use a program that is specifically designed for this and that was/is xmlstarlet.
I do have to add though that i cheated a bit as i got json data before the xml and i transformed it to the xml to actually get the proper data for it. Since i do lack the knowledge to get all json data (although i did try it with jq first), i decided to look for the transformation (Decoding JSON to a PHP Array and then converting it to XML. . GitHub) and then get all data with xmlstarlet. This last part was almost correct then except for the backtracking that i did not know.
Hi,
Can anyone tell the option to change the file type in unix.
i.e. if a file is in csv(Comma Separating Values) format, it should be changed to xls(ordinary MS-Excel) format. But renaming command is not changing to correct file format.
Thanks in advance,
Milton. (1 Reply)
I am trying to check each line and based on first two digits, the comma needs to be place. I checked in the earlier post where the text is converted to csv with a tab delimited.
Here is the test file that needs to be changed to csv
11 051701
22 051701
330123405170105170112345... (13 Replies)
I'm new to shell scripting and I have a file with positional columns. The rows look like this:
222 3333 44444 55 55 55 55 5555 59999
222 3333 44444 55 55 55 55 5555 59999
Not every row has the same number of spaces between the seven columns. They can range anywhere... (11 Replies)
Hello Friends,
I am new to UNIX shell scripting. Using bash....Could you please help me in converting a flat file into an XML style output file.
Flat file: (Input File entries looks like this)
John Miller: 617-569-7996:15 Bunting lane, staten Island, NY: 10/21/79: 60600
The... (4 Replies)
Hej All,
I have a file like this which is a comma dilimited:
input:
6000318,-263.011520678,-59.05869872409,587.67924868792
6000319,-265.6996842902,-50.24902479999,590.65693082607
6000320,-238.1333898366,-288.801232595,633.75332173496... (5 Replies)
Hi Friends,
I want to convert a XML file to flat file.
Sample I/p:
<?xml version='1.0' encoding='UTF-8' ?>
<DataFile xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' contactCount='4999' date='2012-04-14' time='22:00:14' xsi:noNamespaceSchemaLocation='gen
.xsd'>
<Contact... (3 Replies)
I have a table as following
Archive id Line Author Time Text
1fjj34 3 75jk5l 03:20 this is an evidence regarding ...
1fjj34 4 gjhhtrd 03:21 we have seen those documents before
1fjj34 10 645jmdvvb 04:00 Will you consider such an offer?... (0 Replies)
Hi,
I have a xml script, I converted it to .txt with values comma seperated using awk function. But I want the output values should be inside double quotes
My xml script (Workorders.xml) is shown like below:
<?xml version="1.0" encoding="utf-8" ?>
<scbm-extract version="3.3">... (8 Replies)