IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage Perl Discussion :

updat xml file


Sujet :

Langage Perl

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Nouveau candidat au Club
    Homme Profil pro
    Ingénieur systèmes et réseaux
    Inscrit en
    Février 2013
    Messages
    1
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Gabon

    Informations professionnelles :
    Activité : Ingénieur systèmes et réseaux
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Février 2013
    Messages : 1
    Par défaut updat xml file
    please any help;

    i have de folowing xml file ( soap xml file)
    and i want to change the value in <acc1:SubscriberNo>06870565</acc1:SubscriberNo> from 06870565 to new value 073332

    please anu perl script taht can do this

    <soapenv:Envelope
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:acc="http://www.huawei.com/bme/cbsinterface/cbs/accountmgrmsg"
    xmlns:com="http://www.huawei.com/bme/cbsinterface/common"
    xmlns:acc1="http://www.huawei.com/bme/cbsinterface/cbs/accountmgr">
    <soapenv:Header/>
    <soapenv:Body>
    <acc:QueryBalanceRequestMsg>
    <RequestHeader>
    <com:CommandId>QueryBalanceRequest</com:CommandId>
    <com:Version>1</com:Version>
    <com:TransactionId>1</com:TransactionId>
    <com:SequenceId>1</com:SequenceId>
    <com:RequestType>Event</com:RequestType>
    <com:SerialNo>0702149044928111</com:SerialNo>
    </RequestHeader>
    <QueryBalanceRequest>

    <acc1:SubscriberNo>06870565</acc1:SubscriberNo>

    </QueryBalanceRequest>
    </acc:QueryBalanceRequestMsg>
    </env:Body>
    </env:Envelope>

  2. #2
    Membre actif
    Homme Profil pro
    Ingénieur intégration
    Inscrit en
    Décembre 2012
    Messages
    43
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur intégration

    Informations forums :
    Inscription : Décembre 2012
    Messages : 43
    Par défaut
    You can use an inline script, like the following one :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    perl -pi -e "s/\r\n/\n/" mon_fichier.txt
    more sources here : http://www.developpez.net/forums/d10...l-nos-sources/

    It will become :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    perl -pi -e "s/<acc1:SubscriberNo>06870565<\/acc1:SubscriberNo>/<acc1:SubscriberNo>073332<\/acc1:SubscriberNo>/" my_file.xml
    This script will replace the value in your xml file, so first you have to make a back up of your file.

  3. #3
    Rédacteur/Modérateur

    Avatar de Lolo78
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Mai 2012
    Messages
    3 612
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Mai 2012
    Messages : 3 612
    Billets dans le blog
    1
    Par défaut
    Citation Envoyé par Jiheme44 Voir le message
    This script will replace the value in your xml file, so first you have to make a back up of your file.
    Or you can specify an extension for the backup in the command line:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    perl -pi.bak -e 's/search_string/replacement_string/'  my_file.xml
    will modify my_file.xml and backup the orginal file in my_file.bak.

  4. #4
    Rédacteur/Modérateur

    Avatar de Lolo78
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Mai 2012
    Messages
    3 612
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Mai 2012
    Messages : 3 612
    Billets dans le blog
    1
    Par défaut
    The original poster sent me additional question by personal message. Since there is nothing private in this message and in my answer, I copy the whole exchange below, for the benefit of others who may want to add information.

    ===== QUOTE =====

    Citation Envoyé par o.tarki
    but in my situation we did nont now the actual value in 06870565 perl -pi -e "s/<acc1:SubscriberNo>06870565<\/acc1:SubscriberNo>/<acc1:SubscriberNo>073332<\/acc1:SubscriberNo>

    so i want to change the contenant for TAG acc1:SubscriberNo to the new value stored in some variable like my $new_tag=073332.
    In this case, you can do something like this, assuming what you want to replace is a telephone number starting with "06":

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    perl -pi -e 's/<acc1:SubscriberNo>06\d{8}<\/acc1:SubscriberNo>/<acc1:SubscriberNo>073332<\/acc1:SubscriberNo>/;'
    This will replace:
    - <acc1:SubscriberNo>
    - followed by 06 and 8 more digits
    - folloowed by <\/acc1:SubscriberNo>

    with:

    - <acc1:SubscriberNo>
    - followed by 073332
    - followed by <\/acc1:SubscriberNo>

    I assume that's what you are looking for.

    However, I think that your message and my answer are both better fit in the public forum rather than in a personal message, and, since there is nothing personal ot private in our communications, I'll take the freedom to copy this message exchange on the forum. This will enable others to give additional advice if needed.

    ===== UNQUOTE =====

Discussions similaires

  1. Réponses: 1
    Dernier message: 16/11/2006, 13h33
  2. [XML file]Lecture - ecriture :Bienvenue à votre imagination
    Par Terminator dans le forum Format d'échange (XML, JSON...)
    Réponses: 2
    Dernier message: 27/04/2006, 22h53
  3. [Quartz][Tomcat] Jobs.xml file not found exception
    Par Arnaud Giuliani dans le forum Tomcat et TomEE
    Réponses: 1
    Dernier message: 05/08/2005, 09h20
  4. The XML file cannot be displayed
    Par UVCR dans le forum XMLRAD
    Réponses: 2
    Dernier message: 08/03/2005, 16h26
  5. Xml file system storage
    Par sebA dans le forum Décisions SGBD
    Réponses: 1
    Dernier message: 30/09/2004, 07h49

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo