Skip to Content
0
Former Member
Apr 27, 2009 at 09:21 AM

counting how many number of elements in a XML

74 Views

Hi all,<br />

I am having a requirement in ABAP-IXML ie., i need to find how many times a same element name(ComponentUsage) gets repeat in an xml.<br />

here is the xml,<br />

<br />

<Component mmRelease="6.30" mmVersion="2.0" mmTimestamp="1180099591892" name="Comp_three" package="sap.com" masterLanguage="en">

<br />

&lt;Component.ComponentUsages&gt;<br />

&lt;<u><b>ComponentUsage</b></u> lifecycleControl="createOnDemand" name="comp1"&gt;<br />

&lt;ComponentUsage.ComponentControllerUsages&gt;<br />

&lt;ComponentControllerUsage name="Configuration"&gt;<br />

&lt;/ComponentControllerUsage&gt;<br />

&lt;/ComponentUsage.ComponentControllerUsages&gt;<br />

&lt;ComponentUsage.UsedComponent&gt;<br />

<Core.Reference package="sap.com" name="Comp_twoInterface" type="ComponentInterfaceImplementation"/>

&lt;/ComponentUsage.UsedComponent&gt;<br />

&lt;/ComponentUsage&gt;<br />

&lt;/Component.ComponentUsages&gt;<br />

<br />

&lt;Component.ComponentUsages&gt;<br />

&lt;<u><b>ComponentUsage</b></u> lifecycleControl="createOnDemand" name="comp2"&gt;<br />

&lt;ComponentUsage.ComponentControllerUsages&gt;<br />

&lt;ComponentControllerUsage name="Configuration"&gt;<br />

&lt;/ComponentControllerUsage&gt;<br />

&lt;/ComponentUsage.ComponentControllerUsages&gt;<br />

&lt;ComponentUsage.UsedComponent&gt;<br />

<Core.Reference package="sap.com" name="Comp_twoInterface" type="ComponentInterfaceImplementation"/>

&lt;/ComponentUsage.UsedComponent&gt;<br />

&lt;/ComponentUsage&gt;<br />

&lt;/Component.ComponentUsages&gt;<br />

&lt;/Component&gt;<br />

<br />

Here as the xml is short so i manually knows tat the element "ComponentUsage" are used 2 times, but suppose if i use a big xml and the component usage element is used "N" number of times then how can i count mannually....... so is there any method or code to find how many times does "ComponentUsage" element present in an XML.<br />

<br />

Thanks in advance,<br />

Vishnu<br />