Freigeben über


CustomXMLNode.Delete-Methode (Office)

Löscht den aktuellen Knoten aus der Struktur (einschließlich aller untergeordneter Elemente, soweit vorhanden).

Syntax

Ausdruck. Löschen

Ausdruck Ein Ausdruck, der ein CustomXMLNode-Objekt zurückgibt.

HinwBemerkungeneise

Wenn der Vorgang zu einer ungültigen Baumstruktur führen würde, wird der Löschvorgang nicht ausgeführt, und eine Fehlermeldung wird angezeigt.

Beispiel

Im folgenden Beispiel wird das Verwenden verschiedener Methoden zum Hinzufügen von benutzerdefinierten XML-Komponenten, zum Auswählen von Komponenten und Knoten mit unterschiedlichen Kriterien, zum Anfügen untergeordneter Unterstrukturen sowie zum Löschen von Komponenten und Knoten veranschaulicht.

Sub ShowCustomXmlParts() 
    On Error GoTo Err 
 
    Dim cxps As CustomXMLParts 
    Dim cxp1 As CustomXMLPart 
    Dim cxp2 As CustomXMLPart 
    Dim cxn As CustomXMLNode 
    Dim cxns As CustomXMLNodes 
    Dim strXml As String 
    Dim strUri As String 
 
    With ActiveDocument 
        ' Example written for Word. 
 
        ' Adding a custom XML part. 
        .CustomXMLParts.Add "<custXMLPart />" 
         
        ' Add and then load from a file. 
        Set cxp1 = .CustomXMLParts.Add 
        cxp1.Load "c:\invoice.xml" 
         
        ' Returns the first custom XML part with the given root namespace. 
        Set cxp2 = .CustomXMLParts("urn:invoice:namespace")     '  
         
        ' Access all with a given root namespace; returns the entire collection. 
        Set cxps = .CustomXMLParts.SelectByNamespace("urn:invoice:namespace") 
         
        ' DOM-type operations. 
        ' Get the XML. 
        strXml = cxp2.XML 
        ' Get the root namespace 
        strUri = cxp2.NamespaceURI  
        ' Get nodes using XPath.                              
        Set cxn = cxp2.SelectSingleNode("//*[@quantity < 4]")  
        Set cxns = cxp2.SelectNodes("//*[@unitPrice > 20]") 
        ' Append a child subtree to the single node selected previously. 
        cxn.AppendChildSubtree("<discounts><discount>0.10</discount></discounts>")          
         
        ' Delete custom XML part and node and its children. 
        cxp2.Delete 
        cxn.Delete 
 
                 
    End With 
     
    Exit Sub 
                 
' Exception handling. Show the message and resume. 
Err: 
        MsgBox (Err.Description) 
        Resume Next 
End Sub

Siehe auch

Support und Feedback

Haben Sie Fragen oder Feedback zu Office VBA oder zu dieser Dokumentation? Unter Office VBA-Support und Feedback finden Sie Hilfestellung zu den Möglichkeiten, wie Sie Support erhalten und Feedback abgeben können.