DZone
Integration Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Integration Zone > Manipulating XML Files With XPath Strings in IBM UrbanCode Deploy

Manipulating XML Files With XPath Strings in IBM UrbanCode Deploy

Are you looking to manipulate your XML files with your IBM UrbanCode Deploy server? If so, you are not alone!

Tim McMackin user avatar by
Tim McMackin
·
Jan. 18, 17 · Integration Zone · Opinion
Like (1)
Save
Tweet
3.10K Views

Join the DZone community and get the full member experience.

Join For Free

I’m learning that people really want to manipulate XML files with their IBM UrbanCode Deploy servers! We get so many questions about the Update XML With XPath automation step (both through the forum and through direct contact) that I wrote an article about some common things that come up when people want to edit XML files as part of their deployment automation.

We still get a ton of XPath questions!

The most common use case seems to be a server configuration that needs an edit when a new application or version of an application gets deployed. However, this step can edit just about any XML file, though there are some gotchas and idiosyncrasies that are listed in the article. (I might go into some detail about those in a later post.)

The basics are pretty simple. First, you give the step the name and location of an XML file or files. Then, you give it some rules for changes to make in the XML file. To tell the step to change some text, for example, you give it an XPath string that points to the text, then a little text “arrow” (->), and then the new text.

For example, here’s some sample XML from the article:

<?xml version="1.0" encoding="UTF-8"?>
<testFile>
  <myData>
    <data name="filePath" value="/opt/sampleDirectory"/>
    <data name="textData">Here is some text.</data>
    <data att1="one" att2="two" name="attributes" value="something"/>
  </myData>
</testFile> 

To change an attribute value, you use an XPath string that points to that attribute, and then you put in the new text. For example, to change the /opt/sampleDirectory to /usr/otherDirectory, put this in the Replace with text field: //testFile/myData/data[@value]/@value->/usr/otherDirectory 

To change the text of a node, refer to it as text(). For example: 

//testFile/myData/data[@name='textData']/text()->Some new text content.

There are also steps to add and remove XML nodes.

Got an unusual file that you need to make changes to as part of your deployment automation? Keep the XPath questions coming and we’ll answer as many as we can.

XML XPath Strings

Published at DZone with permission of Tim McMackin, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • 5 Myths of Kubernetes
  • My Sentiments, Erm… Not Exactly
  • Low Code and No Code: The Security Challenge
  • Top ALM Tools and Solutions Providers

Comments

Integration Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo