#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    14
    Rep Power
    0

    Parse XML and update the values between the tags


    Hi Perl programming team,

    I am working on the XML parsing and I have the XML as

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
    <groupId>com.ma.def.gre</groupId>
    <artifactId>basepom</artifactId>
    <version>9.7</version>
    </parent>

    <groupId>com.mathworks.matlabserver</groupId>
    <artifactId>matlabserver</artifactId>
    <packaging>pom</packaging>
    <version>9.7.1-DEF-SNAPSHOT</version>
    <name>ABC Server multi-module project</name>
    <inceptionYear>2009</inceptionYear>
    <url>http://inside.mathworks.com/wiki/Category:WIT</url>
    <description>The root POM for project.</description>

    <modules>
    <!-- <module>cripts</module>
    <module>webapp</module> -->
    <module>server</module>
    <module>abc</module>
    <module>ufr</module>
    <!-- <module>def-webapp</module> -->
    </modules>

    <properties>
    <netbeans.hint.deploy.server>J2EE</netbeans.hint.deploy.server>
    <flex.messaging.version>3.2</flex.messaging.version>
    <spring.framework.version>2.5.5</spring.framework.version>
    <easymock.version>2.4</easymock.version>
    <mlslibs.version>9.7</mlslibs.version>
    </properties>

    <build>
    <pluginManagement>
    <plugins>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-report-plugin</artifactId>
    <version>2.8</version>
    </plugin>
    <plugin>
    <artifactId>maven-site-plugin</artifactId>
    <version>3.0</version>
    </plugin>
    </plugins>
    </pluginManagement>
    </build>

    </project>


    in the above XML i need to update the values between
    version tag which comes under the <parent> and the other comes under <project> but the issue is that the we have many version tags in <project> and I am unable to understand how to sort this issue with programming.

    to be precise i only need to replace the values between the version tag which are
    <version>9.7</version> and
    <version>9.7.1-DEF-SNAPSHOT</version>

    Thanks!!!!
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2009
    Posts
    335
    Rep Power
    246
    You could use an XML module such as XML::Twig and regular expressions (substitution).
    Free MP3 Dance Music Downloads

    To err is human; To really balls things up you need Microsoft!

IMN logo majestic logo threadwatch logo seochat tools logo