Inserting more than once

2011-02-23
2013-05-15
  • Vinaya Kumar
    Vinaya Kumar
    2011-02-23

    Hello Sir,
    When i use method InsertAfterElement() , it inserting more than once .. how can i  insert only once ..

    Xml file :
    <?xml version="1.0" encoding="UTF-8"?>
    <resource-lists xmlns="urn:ietf:params:xml:ns:resource-lists">
    <list name="oma_pocbuddylist">
    <entry uri="tel:+99999">
                <display-name>Contact8</display-name>
            <display-name>Contact 9</display-name>
    </entry>
    </>
    xpath                                : "/resource-lists/list/entry/display-name";
    element to be inserted :  <display-name>Contact 10</display-name>

    Output XMLFILE:

    <?xml version="1.0" encoding="UTF-8"?>
    <resource-lists xmlns="urn:ietf:params:xml:ns:resource-lists">
    <list name="oma_pocbuddylist">
    <entry uri="tel:+99999">
                <display-name>Contact8</display-name><display-name>Contact 10</display-name>
          <display-name>Contact 9</display-name> <display-name>Contact 10</display-name>
    </entry>
    </></>

    But i need out put as :
    <?xml version="1.0" encoding="UTF-8"?>
    <resource-lists xmlns="urn:ietf:params:xml:ns:resource-lists">
    <list name="oma_pocbuddylist">
    <entry uri="tel:+99999">
                <display-name>Contact8</display-name>
          <display-name>Contact 9</display-name> <display-name>Contact 10</display-name>
    </entry>
    </></>

     
  • jimmy zhang
    jimmy zhang
    2011-02-26

    I think this is a bug of your code, you should use the xpath

    "/resource-lists/list/entry/display-name";