我需要根据每条记录中的另一个元素值获取一个元素值。
如果 RECORD_TYPE='ERROR' 那么我必须为 ERRORS:ERROR_DESC 下的所有记录打印所有不同(唯一)的 ERROR_DESC 值
每个错误描述都应打印在新行中。
<root>
<SellOutRecord>
<RECORD_TYPE>ERROR</RECORD_TYPE>
<ERROR_DESC>record 1:location id is invalid</ERROR_DESC>
<RECORD_NO>1</RECORD_NO>
<LOCATION_NAME>XYZ el</LOCATION_NAME>
<PRODUCT_NUMBER>336549R-001</PRODUCT_NUMBER>
<PRODUCT_OPTION>0D1</PRODUCT_OPTION>
<PRODUCT_LINE>LA</PRODUCT_LINE>
</SellOutRecord>
<SalesInRecord>
<RECORD_TYPE>ERROR</RECORD_TYPE>
<ERROR_DESC>record 1:location id is invalid</ERROR_DESC>
<RECORD_NO>1</RECORD_NO>
<LOCATION_NAME>XYZ el</LOCATION_NAME>
<PRODUCT_NUMBER>336549R-001</PRODUCT_NUMBER>
<PRODUCT_OPTION>0D1</PRODUCT_OPTION>
<PRODUCT_LINE>LA</PRODUCT_LINE>
<PRODUCT_LINE_TYPE>C</PRODUCT_LINE_TYPE>
</SalesInRecord>
<SellOutRecord>
<RECORD_TYPE>ERROR</RECORD_TYPE>
<ERROR_DESC>record 2:location id is invalid</ERROR_DESC>
<RECORD_NO>2</RECORD_NO>
<LOCATION_NAME>XYZ el</LOCATION_NAME>
<PRODUCT_NUMBER>3X-KN73C-DB</PRODUCT_NUMBER>
<PRODUCT_OPTION>0D1</PRODUCT_OPTION>
<PRODUCT_LINE>HA</PRODUCT_LINE>
<PRODUCT_LINE_TYPE>E</PRODUCT_LINE_TYPE>
</SellOutRecord>
<SellOutRecord>
<RECORD_TYPE>ERROR</RECORD_TYPE>
<ERROR_DESC>record 3:SO:transaction currency is invalid</ERROR_DESC>
<RECORD_NO>3</RECORD_NO>
<LOCATION_NAME>XYZ el</LOCATION_NAME>
<PRODUCT_NUMBER>339112-B25</PRODUCT_NUMBER>
<PRODUCT_OPTION>0D1</PRODUCT_OPTION>
<PRODUCT_LINE>J3</PRODUCT_LINE>
<PRODUCT_LINE_TYPE>E</PRODUCT_LINE_TYPE>
</SellOutRecord>
<SalesInRecord>
<RECORD_TYPE>ERROR</RECORD_TYPE>
<ERROR_DESC>record 2:location id is invalid</ERROR_DESC>
<RECORD_NO>3</RECORD_NO>
<LOCATION_NAME>XYZ el</LOCATION_NAME>
<PRODUCT_NUMBER>339112-B25</PRODUCT_NUMBER>
<PRODUCT_OPTION>0D1</PRODUCT_OPTION>
<PRODUCT_LINE>J3</PRODUCT_LINE>
<PRODUCT_LINE_TYPE>E</PRODUCT_LINE_TYPE>
</SalesInRecord>
<SalesInRecord>
<RECORD_TYPE>ERROR</RECORD_TYPE>
<ERROR_DESC>record 3:SI:transaction document id is invalid</ERROR_DESC>
<RECORD_NO>3</RECORD_NO>
<LOCATION_NAME>XYZ el</LOCATION_NAME>
<PRODUCT_NUMBER>339112-B25</PRODUCT_NUMBER>
<PRODUCT_OPTION>0D1</PRODUCT_OPTION>
<PRODUCT_LINE>J3</PRODUCT_LINE>
<PRODUCT_LINE_TYPE>E</PRODUCT_LINE_TYPE>
</SalesInRecord>
<SalesInRecord>
<RECORD_TYPE>ERROR</RECORD_TYPE>
<ERROR_DESC>record 5:SI:transaction currency is null or invalid</ERROR_DESC>
<RECORD_NO>5</RECORD_NO>
<LOCATION_NAME>XYZ el</LOCATION_NAME>
<PRODUCT_NUMBER>339112-B25</PRODUCT_NUMBER>
<PRODUCT_OPTION>0D1</PRODUCT_OPTION>
<PRODUCT_LINE>J3</PRODUCT_LINE>
<PRODUCT_LINE_TYPE>E</PRODUCT_LINE_TYPE>
</SalesInRecord>
<InventoryRecord>
<RECORD_TYPE>ERROR</RECORD_TYPE>
<ERROR_DESC>record 6:product id is invalid</ERROR_DESC>
<RECORD_NO>6</RECORD_NO>
<LOCATION_NAME>XYZ XYZ</LOCATION_NAME>
<PRODUCT_NUMBER>331184-B21</PRODUCT_NUMBER>
<PRODUCT_OPTION>0S1</PRODUCT_OPTION>
<PRODUCT_LINE>R8</PRODUCT_LINE>
<PRODUCT_LINE_TYPE>E</PRODUCT_LINE_TYPE>
</InventoryRecord>
<SellOutRecord>
<RECORD_TYPE>ERROR</RECORD_TYPE>
<ERROR_DESC>record 6:SO:invoiced net amount is invalid</ERROR_DESC>
<RECORD_NO>6</RECORD_NO>
<LOCATION_NAME>XYZ el</LOCATION_NAME>
<PRODUCT_NUMBER>339112-B25</PRODUCT_NUMBER>
<PRODUCT_OPTION>0D1</PRODUCT_OPTION>
<PRODUCT_LINE>J3</PRODUCT_LINE>
<PRODUCT_LINE_TYPE>E</PRODUCT_LINE_TYPE>
</SellOutRecord>
<SellOutRecord>
<RECORD_TYPE>VALID</RECORD_TYPE>
<RECORD_NO>7</RECORD_NO>
<LOCATION_NAME>XYZ el</LOCATION_NAME>
<PRODUCT_NUMBER>339112-B25</PRODUCT_NUMBER>
<PRODUCT_OPTION>0D1</PRODUCT_OPTION>
<PRODUCT_LINE>J3</PRODUCT_LINE>
<PRODUCT_LINE_TYPE>E</PRODUCT_LINE_TYPE>
</SellOutRecord>
<SellInRecord>
<RECORD_TYPE>VALID</RECORD_TYPE>
<RECORD_NO>7</RECORD_NO>
<LOCATION_NAME>XYZ el</LOCATION_NAME>
<PRODUCT_NUMBER>339112-B25</PRODUCT_NUMBER>
<PRODUCT_OPTION>0D1</PRODUCT_OPTION>
<PRODUCT_LINE>J3</PRODUCT_LINE>
<PRODUCT_LINE_TYPE>E</PRODUCT_LINE_TYPE>
</SellInRecord>
</root>
预期输出为:
<root>
<ERROR>record 1:location id is invalid</ERROR>
<ERROR>record 2:location id is invalid</ERROR>
<ERROR>record 3:SO:transaction currency is invalid</ERROR>
<ERROR>record 3:SI:transaction document id is invalid</ERROR>
<ERROR>record 5:SI:transaction currency is null or invalid</ERROR>
<ERROR>record 6:product id is invalid</ERROR>
<ERROR>record 6:SO:invoiced net amount is invalid</ERROR>
</root>
提前致谢。