#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    2
    Rep Power
    0

    Removing tag by text stored in it


    Hie , I am using DOM ,
    <?xml version="1.0" encoding="UTF-8" standalone="no">
    <SideBar>

    <Box>party</Box>
    <Box>Event</Box>

    <party>BirthdayParty</party>
    <party>GetTogetherParty</party>

    <Event>LeasureEvent</Event>
    <Event>SomeEvent</Event>
    </SideBar>

    here i want to delete //<party>GetTogetherParty</party>
    How Can I do that ...!
    m working from long ... need help..!
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    2
    Rep Power
    0
    got it:
    Node staff = doc.getElementsByTagName("SideBar").item(0);

    Element SideBar = doc.getDocumentElement();
    NodeList Box = SideBar.getElementsByTagName(BoxName);

    for (int j=0; j<Box.getLength(); j++ )
    {
    Node BoxItem = Box.item(j);
    if ( isTextNode(BoxItem))
    continue;
    String strBoxName=BoxItem.getTextContent();
    if(strBoxName.equals(PageName))
    {
    staff.removeChild(BoxItem);
    }
    }

IMN logo majestic logo threadwatch logo seochat tools logo