Search code examples
xmltagsvtd-xml

Is there any way to find end tag in xml using vtd-xml


I have use token to loop all element based on the token count and see that in my xml structure, it has only token type = 5 and token type = 0 from this web

http://vtd-xml.sourceforge.net/userGuide/6.html

So is there a way to find ending tag in vtd-xml

Because, I have xml look like this.

<ZDA>
<userdata>
    <firstname>Eak</firstname>
    <lastname>Tan</lastname>
</userdata>
<list name="employee">
    <entry>
        <first_name>firstName</first_name>
        <title>title</title>
        <empid>1</empid>
        <second_name>secondName</second_name>
        <last_name>lastName</last_name>
        <date_of_birth>dateOfBirth</date_of_birth>
        <pin>pin</pin>
        <province>province</province>
        <start_date>startDate</start_date>
        <list name="address">
            <entry>
                <addressid>1</addressid>
                <empid>1</empid>
                <sequence>1</sequence>
                <detail>address11</detail>
            </entry>
            <entry>
                <addressid>2</addressid>
                <empid>1</empid>
                <sequence>2</sequence>
                <detail>address12</detail>
            </entry>
            <entry>
                <addressid>3</addressid>
                <empid>1</empid>
                <sequence>3</sequence>
                <detail>address13</detail>
            </entry>
        </list>
    </entry>    
</list>

I use ap.iterate() to loop through all the xml structure.

I want to use end tag to indicate that when it is reach --> </entry> add object to the current list. When it reach --> </list> add these list to the upper object if it have outer list.

And I want this procedure to be like a library so I use reflect to call method and object.

Right now, I only have a problem with how can the program know where to add accordingly.

So is any way to get end tag or parse XML to let it have end tags.

Best Regard, Thank you.


Solution

  • Ending tag is not kept by the vtd parser, because it is the same as th starting tag. Any reason you are looking for ending tags?