xpath...

<[email protected]>
Newsgroups gmane.text.xml.french.tech
Message-ID <01f101c6a0f3$7c6dde30$0201a8c0@JARLIER>
Another question as well...:

If I have this XML:

<config evaluator="string-compare" condition="Function" maxId="6">
      <children>
         <child id="General Director" level="100" active="true">
         	<labels/>
		<children>
         		<child id="Director (Private Bank)" level="80"
active="true">
        			<labels/>
      	            <children>
         				<child id="Director (Entreprise)"
level="60" active="true">
        					<labels/>
			         		<!--children>
	
......................................
			         		</children-->
      				</child>
         			</children>
      		</child>
	      </children>
	 </child>		
     </children>
   </config>

Is it false to use this path to get the Element node Director (Private
Bank)?

String xpath = "/config/children//child[@id=' Director (Private Bank)']";

Thanks in advance for your answer.
Sophie 


-----Message d'origine-----
De : [email protected] [mailto:[email protected]] De la part
de [email protected]
Envoyé : mercredi 5 juillet 2006 15:58
À : [email protected]
Objet : [xml-tech] [xml-tech]getChildNodes()

Bonjour,

En parsant mon XML j’ai une erreur qui apparemment est une erreur d’espace :

INFO  [STDOUT] Exception :
2006-07-05 15:38:22,896 INFO  [STDOUT] java.lang.ClassCastException:
org.apache.xerces.dom.DeferredTextImpl

Quand je fais ca:
 

if(allLevels = true)
{

          NodeList children = dimElt.getChildNodes();    //IS NOT NULL
	    
          for(int i=0; i<children.getLength(); i++)
          {
		Node node = children.item(i);
            Element elt = (Element)node;   //PROBLEM HERE

		NodeList listChild =
elt.getElementsByTagName(EthicFlow_DomXMLConfigConstants.ELEMENT_CHILD);
	
for(int j=0; j<listChild.getLength(); j++)
            {
		    Node childnode = listChild.item(j);
                Element childElt = (Element)childnode;
                String name = domXMLParser_getElementValue(childElt);
                list.add(name);
}
         }
}

 Pensez-vous que cela soit dû à des espaces dans mon XML ? :

 
<child id="Director (Private Bank)" level="80" active="true">
     <labels>
           <label lang="en">Director (Private Bank)</label>
            <label lang="fr">Directeur (Banque Privée)</label>
     </labels>
     <children>
           <child id="Director (Entreprise)" level="60" active="true">
               <labels>
                       <label lang="en">Director (Entreprise) </label>
                        <label lang="fr">Directeur (Clientèle
Entreprise)</label>
                </labels>
                 <!--children>
                                   ......................................
                 </children-->
           </child>
      </children>
</child>


En plus je ne peux pas utiliser autre chose que ce getChildNodes() parce que
si je cherche en faisant :

getElementByTagName(« Children ») et ensuite getElementByTagName(« child »)
je vais avoir des redondances.

Comment puis-je résoudre ca ?
Merci d'avance 
A+
Sophie


--
Devenez redacteur <XML>fr et contribuez au developpement du
xml francophone (http://xmlfr.org/infos/redacteurs/) !

Liste de diffusion "[email protected]" (http://xmlfr.org).

Cette liste est a votre disposition pour discuter en francais de 
tout sujet technique lie a XML.

Pour resilier votre abonnement, envoyez un message contenant 
la commande "unsubscribe" a [email protected]
(mailto:[email protected]?Subject=unsubscribe)


__________ NOD32 1.1644 (20060704) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.