Skip to main content
Tweeted twitter.com/StackUnix/status/753731755752853504

how How to parse xmlfilean xml file in shellscripta shell script

I would like to know how can I split my data from the following format:

<datas>
 <data>
  <name>Name1</name>
 </data>
 <data>
  <name>Name2</name>
 </data>
</datas>

to the following format.:

<data><name>Name1</name></data>
<data><name>Name2</name></data>

The parsed data would be sent to a Python script as followedfollows:

 python script.py <data><name>Name1<name></data>
 python script.py <data><name>Name2<name></data>

I have tried commands like:

echo 'cat /datas/data' | xmllint --shell file.xml

but I do not know how to storecan I pass the output in a variable and use for loop to sent it to the python script

or other meansdesired format to achieve the same resultsPython script?

how to parse xmlfile in shellscript

I would like to know how can I split my data from the following format:

<datas>
 <data>
  <name>Name1</name>
 </data>
 <data>
  <name>Name2</name>
 </data>
</datas>

to the following format.

<data><name>Name1</name></data>
<data><name>Name2</name></data>

The parsed data would be sent to a Python script as followed:

 python script.py <data><name>Name1<name></data>
 python script.py <data><name>Name2<name></data>

I have tried commands like

echo 'cat /datas/data' | xmllint --shell file.xml

but I do not know how to store in a variable and use for loop to sent it to the python script

or other means to achieve the same results

How to parse an xml file in a shell script

I would like to know how can I split my data from the following format:

<datas>
 <data>
  <name>Name1</name>
 </data>
 <data>
  <name>Name2</name>
 </data>
</datas>

to the following format:

<data><name>Name1</name></data>
<data><name>Name2</name></data>

The parsed data would be sent to a Python script as follows:

 python script.py <data><name>Name1<name></data>
 python script.py <data><name>Name2<name></data>

I have tried commands like:

echo 'cat /datas/data' | xmllint --shell file.xml

but how can I pass the output in the desired format to the Python script?

edited tags
Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 264
added 24 characters in body
Source Link
Aryise
  • 63
  • 1
  • 1
  • 5

I would like to know how can I split my data from the following format:

<datas>
 <data>
  <name>Name1</name>
 </data>
 <data>
  <name>Name2</name>
 </data>
</datas>

to the following format.

<data><name>Name1</name></data>
<data><name>Name2</name></data>

The parsed data would be sent to a Python script as followed:

 python script.py <data><name>Name1<name></data>
 python script.py <data><name>Name2<name></data>

I have tried commands like

echo 'cat /datas/data' | xmllint --shell file.xml

but I do not know how to store in a variable and use for loop to sent it to the python script

or other means to achieve the same results Although I have other ideas or workaround, for instance using Python script to parse and execute the robot, but I hope to see if there is such possibility to use .sh file to do it. :)

I would like to know how can I split my data from the following format:

<datas>
 <data>
  <name>Name1</name>
 </data>
 <data>
  <name>Name2</name>
 </data>
</datas>

to the following format.

<data><name>Name1</name></data>
<data><name>Name2</name></data>

The parsed data would be sent to a Python script as followed:

 python script.py <data><name>Name1<name></data>
 python script.py <data><name>Name2<name></data>

I have tried commands like

echo 'cat /datas/data' | xmllint --shell file.xml

but I do not know how to store in a variable and use for loop to sent it to the python script

or other means to achieve the same results Although I have other ideas or workaround, for instance using Python script to parse and execute the robot, but I hope to see if there is such possibility to use .sh file to do it. :)

I would like to know how can I split my data from the following format:

<datas>
 <data>
  <name>Name1</name>
 </data>
 <data>
  <name>Name2</name>
 </data>
</datas>

to the following format.

<data><name>Name1</name></data>
<data><name>Name2</name></data>

The parsed data would be sent to a Python script as followed:

 python script.py <data><name>Name1<name></data>
 python script.py <data><name>Name2<name></data>

I have tried commands like

echo 'cat /datas/data' | xmllint --shell file.xml

but I do not know how to store in a variable and use for loop to sent it to the python script

or other means to achieve the same results

added 24 characters in body
Source Link
Aryise
  • 63
  • 1
  • 1
  • 5
Loading
added 173 characters in body
Source Link
Aryise
  • 63
  • 1
  • 1
  • 5
Loading
added 197 characters in body
Source Link
Aryise
  • 63
  • 1
  • 1
  • 5
Loading
Formatting of XML. Removed `macintosh` tag.
Source Link
Kusalananda
  • 355.7k
  • 42
  • 735
  • 1.1k
Loading
Source Link
Aryise
  • 63
  • 1
  • 1
  • 5
Loading