So the problem is I am trying to use AWK, Perl to find how many records are inside one xml that is one loooong line sometimes in the megabytes.
Most if not all examples I've seen are assuming a nice structured xml like
<?xml version="1.0" encoding="UTF-8"?>
<spendownrequest xmlns="http://www.foo.com/Adv/HR/SSt">
<spenddowndata>
<employeeId>0002</employeeId>
<transactionId>103</transactionId>
<transactionType>T</transactionType>
</spenddowndata>
<spenddowndata>
<employeeId>0003</employeeId>
<transactionId>104</transactionId>
<transactionType>T</transactionType>
</spenddowndata>
<spenddowndata>
<employeeId>0004</employeeId>
<transactionId>105</transactionId>
<transactionType>T</transactionType>
</spenddowndata>
</spendownrequest>
with newlines at each row. These files are like this
<?xml version="1.0" encoding="UTF-8"?><spendownrequest xmlns="http://www.foo.com/Adv/HR/SSt">
<spenddowndata><employeeId>0002</employeeId><transactionId>103</transactionId>
<transactionType>T</transactionType></spenddowndata><spenddowndata><employeeId>0003</employeeId>
<transactionId>104</transactionId><transactionType>T</transactionType></spenddowndata><spenddowndata>
<employeeId>0005</employeeId><transactionId>105</transactionId><transactionType>T</transactionType>
</spenddowndata></spendownrequest>
One long line with only (1) newline at the end.
I tried:
awk -F'[<|>]' '/spenddowndata/ {i++} { print i }' file.xml
get back 1
How would I get the count for all 3 that are in this file?