Suppression noeud XML

Résolu/Fermé
SPEUTA Messages postés 55 Date d'inscription lundi 16 mai 2011 Statut Membre Dernière intervention 16 avril 2014 - 4 nov. 2013 à 16:42
SPEUTA Messages postés 55 Date d'inscription lundi 16 mai 2011 Statut Membre Dernière intervention 16 avril 2014 - 4 nov. 2013 à 17:08
Bonjour,

J'ai une macro excel en vba qui génère un fichier XML, et une fois généré, je le re-parcours pour filter les balises <printer>

plan d'un XML :

<pagination>
<title>
<printer>
<main/>
</printer>
<printer>
<main>
<page />
<page />
</main>
</printer>
</title>
</pagination>

Ce que je voudrais faire c'est supprimer un noeud <printer> si il ne contient pas de <page>

Voici mon code :

For Each objNode In objDoc.SelectNodes("//printer")
If ("C'est ici que je bloque") Then
objNode.ParentNode.RemoveChild objNode
End If
Next

Avez vous une solution ? Merci d'avance
A voir également:

1 réponse

SPEUTA Messages postés 55 Date d'inscription lundi 16 mai 2011 Statut Membre Dernière intervention 16 avril 2014 4
4 nov. 2013 à 17:08
J'ai fini par trouver la solution.
Pour ceux qui auraient le même problème :

For Each objNode In objDoc.SelectNodes("//main")
If objNode.FirstChild Is Nothing Then
objNode.ParentNode.ParentNode.RemoveChild objNode.ParentNode
End If
Next
0