xml-xmlbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Springer, Ian P." <ian.sprin...@hp.com>
Subject RE: Deleting an XmlObject
Date Fri, 09 Jul 2004 13:18:58 GMT
One way to do it is to get an XmlCursor, navigate to the node you want
to delete and then call the removeXml() method. For example, here's a
method I wrote to delete a namespace declaration:

   public static boolean removeNamespace( final XmlCursor xmlCursor,
final String nsURI )
   {
      if ( nsURI == null )
      {
         return false;
      }
      for ( XmlCursor.TokenType tokenType = xmlCursor.toNextToken();
!tokenType.equals( XmlCursor.TokenType.NONE ); tokenType =
xmlCursor.toNextToken() )
      {
         if ( tokenType.equals( XmlCursor.TokenType.NAMESPACE ) )
         {
            if ( xmlCursor.getName() != null && nsURI.equals(
xmlCursor.getName().getNamespaceURI() ) )
            {
               xmlCursor.removeXml();
               return true;
            }
         }
      }
      return false;
   }


Ian 

| -----Original Message-----
| From: Saha, Sanjeev [mailto:SSaha@asce.org] 
| Sent: Friday, July 09, 2004 8:42 AM
| To: xmlbeans-user@xml.apache.org
| Subject: Deleting an XmlObject
| 
| How can one simulate a node deletion feature like in dom4j that allows
| us to drop a node as node.getParent().remove(node)?
| 
| -Sanjeev
| 
| - 
| ---------------------------------------------------------------------
| To unsubscribe, e-mail:   xmlbeans-user-unsubscribe@xml.apache.org
| For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
| Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/
| 
| 
| 

- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/


Mime
View raw message