0

I've a input file that calls numbers.txt which contains something like below.

<msisdn>678678678678</msisdn>

<msisdn>456456456456</msisdn>

<msisdn123123123123</msisdn>

and xml files as below

[root@ app]# cat test.xml
<soapenv:Envelope xmlns:soapenv="http://5tu6.com/net/" xmlns:net="http://5tu6.com/net"><soapenv:Header/><soapenv:Body><net:querySubscriberSettingsRequest><requestId>103</requestId><msisdn>25252623</msisdn></net:querySubscriberSettingsRequest></soapenv:Body></soapenv:Envelope>

What I want is, in below while loop, I would like to take each entry from numbers.txt replace it with existing msisdn part in test.xml, increase the requestId +1 in each time. Also in that while loop at the end, run curl command each time as with new entries.

while IFS= read -r line; do
    echo "$line"
done < number.txt
GND
  • 25
  • 6
  • 5
    In general, XML-aware tools should be used to parse and generate XML. Hackery with tools intended for managing plain text is intrinsically fragile. – Charles Duffy Mar 14 '23 at 14:40
  • 1
    [xmlstarlet](https://xmlstar.sourceforge.net/) supports transformation of XML to and from pyx -- a language intended to be easy for tools like awk/sed/etc to process. If you aren't willing to just use a different language (which is _really_ what I recommend here: Python comes with some great XML libraries out-of-the-box), it's a good fallback choice. – Charles Duffy Mar 14 '23 at 14:41
  • 1
    See: https://stackoverflow.com/questions/6751105/why-its-not-possible-to-use-regex-to-parse-html-xml-a-formal-explanation-in-la – Cyrus Mar 14 '23 at 17:08
  • What is the question? – Wintermute Mar 20 '23 at 13:05

0 Answers0