Re: utiliser Xercès pour parser un InputStream ou String?

<[email protected]>
Newsgroups gmane.text.xml.french.tech
Message-ID <01b401c67b29$76bb4da0$0201a8c0@JARLIER>
Merci pour ta réponse. text()  c'est pour quoi en fait? Pour dire que le nœud est de type text? Mon problème venait du getNodeValue() :)
A+

-----Message d'origine-----
De : [email protected] [mailto:[email protected]] De la part de Jean-Marc Desprez
Envoyé : vendredi 19 mai 2006 11:18
À : [email protected]
Objet : [xml-tech] Re: utiliser Xercès pour parser un InputStream ou String?

Salut,
Comme ça, vite fait je te conseil ça
String xpath = "/alf-config/procedure-condition/text()";
parce que "condition" est en fait le noeud texte dans ton xml
Je n'ai pas testé, dit moi si ça règle ton problème (je pense que oui)

A+


Le 19/05/06, [email protected] <[email protected]> a écrit :
>
> Merci infiniment.
>
> J'ai quelques soucis pour récupérer la valeur stockée entre tag.
> S'il vous plait pourriez-vous me dire ce que je fais de faux?
>
> J'ai un XML comme suit (en plus complexe):
>
> <?xml version="1.0" encoding="UTF-8"?>
> <alf-config>
>         <label>label</label>
>         <!--comment-->
>         <procedure-condition>condition</procedure-condition>
> </alf-config>
>
> Ensuite j'appelle mon constructeur avec le contenu de mon XML (un String):
>
> public EthicFlow_DomXMLParser(String xmlContent)
> {
>         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
>
>         try {
>
>                 // ** Using factory get an instance of document builder
>                 DocumentBuilder db = dbf.newDocumentBuilder();
>
>                 // ** Reader Writer creation from xmlContent
>                 this.in = new StringReader(xmlContent);
>               this.out = new StringWriter();
>
>               // ** Parse using builder to get DOM representation of the
> XML
> //file
>                 this.dom = db.parse(new InputSource(this.in));
>
>                 }catch(ParserConfigurationException pce) {
>                         pce.printStackTrace();
>                 }catch(SAXException se) {
>                         se.printStackTrace();
>                 }catch(IOException ioe) {
>                         ioe.printStackTrace();
>                 }
> }
>
> Et ensuite je veux récupérer procedure-condition c'est-a-dire "condition"
> comme ceci:
>
> public String domXMLParser_getProcedureCondition()
> {
>         String procedureCondition = null;
>         try
>         {
>                 String xpath = "/alf-config/procedure-condition";
> NodeList nl = XPathAPI.selectNodeList(this.dom, xpath);
>                 Element element = (Element)nl.item(0);
>                 procedureCondition = element.getNodeValue();
>
>         }
>         catch(TransformerException te){
>
> Utils.addErrorMessage(MessageFormat.format(Application.getMessage
> (FacesConte
> xt.getCurrentInstance(), "TransformerException"), te
>                                .getMessage()), te);
> //te.printStackTrace();
>         }
>
>         return procedureCondition;
> }
>
> Et ca ne plante pas mais je récupère null au lieu de "condition"...
>
> Merci d'avance
> 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.1547 (20060518) 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.