Skip to Content
0
Jan 20, 2020 at 01:05 PM

Count How many times the userid is exist in the xml

61 Views Last edit Jan 20, 2020 at 01:35 PM 2 rev

Hi All,
I have a small required in which I need to count how many times the user exists in the payload, am using the XSLT but still, it is not is overcoming the output.

XML:

<?xml version="1.0"?> <Request> <Request> <RequestUNav> <RequestUData> <businessUnit/> <isEffectiveDateType>false</isEffectiveDateType> <actionType></actionType> <isAssigned>false</isAssigned> <UserId>UserTest</UserId> <effectiveDate/> <subjectUserName>Testing 123</subjectUserName> </RequestUData> </RequestUNav> </Request> <Request> <RequestUNav> <RequestUData> <businessUnit/> <isEffectiveDateType>false</isEffectiveDateType> <actionType></actionType> <isAssigned>false</isAssigned> <UserId>UserTest</UserId> <effectiveDate/> <subjectUserName>123</subjectUserName> </RequestUData> </RequestUNav> </Request> <Request> <RequestUNav> <RequestUData> <businessUnit/> <isEffectiveDateType>false</isEffectiveDateType> <actionType></actionType> <isAssigned>false</isAssigned> <UserId>Test</UserId> <effectiveDate/> <subjectUserName>1234</subjectUserName> </RequestUData> </RequestUNav> </Request> </Request>

XSLT code:

http://www.w3.org/1999/XSL/Transform"> UserId--

Expected Output:

<?xml version="1.0" encoding="UTF-8"?><Response><UserId>UserTest</UserId><Reflect>2</Reflect><UserId>Test</UserId><Reflect>1</Reflect></Response>

Regards,
Sandhya