473,385 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Find and Replace within an XML file

I was wondering if there is a simple method of replacing characters within
the xml document.

I'm looking at writing a Biztalk Pipeline that escapes illegal characters
before they are processed by a HL7 assembler.

I.E. replace all instances of & or & with \T\ .

I thought about converting to a string and using the replace function, but
that would mean knownig all the HTML codes for characters (as the escape
characters are to be dynamically chosen by the user). Where as I could via
xpath ??? replace all instances of the original character such as &.

Hope it makes sense.

Thanks!
Dec 14 '06 #1
1 4824
Namshub wrote:
I was wondering if there is a simple method of replacing characters within
the xml document.
Several languages will do this, notably XSLT, although XSLT 1.0 isn't
very good at string manipulation. XSLT 2 is much better, but less well
supported yet.
I'm looking at writing a Biztalk Pipeline that escapes illegal characters
before they are processed by a HL7 assembler.

I.E. replace all instances of & or & with \T\ .
None of those characters are illegal in XML.
I thought about converting to a string and using the replace function, but
that would mean knownig all the HTML codes for characters (as the escape
characters are to be dynamically chosen by the user). Where as I could via
xpath ??? replace all instances of the original character such as &.

Hope it makes sense.
Not really. If you want to do large-scale character filtering, and you
have a robust model for avoiding trespassing on the markup, it will be
faster to use a stream editor than to write it in a language which needs
to invoke a formal parse of the XML document first. But you do need to
know what you're doing with it.

///Peter
--
XML FAQ: http://xml.silmaril.ie/
Dec 14 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: hokieghal99 | last post by:
import os, string print " " setpath = raw_input("Enter the path: ") def find_replace(setpath): for root, dirs, files in os.walk(setpath): fname = files for fname in files: find =...
1
by: Xah Lee | last post by:
suppose you want to do find & replace of string of all files in a directory. here's the code: ©# -*- coding: utf-8 -*- ©# Python © ©import os,sys © ©mydir= '/Users/t/web'
19
by: rbt | last post by:
Here's the scenario: You have many hundred gigabytes of data... possible even a terabyte or two. Within this data, you have private, sensitive information (US social security numbers) about your...
1
by: Mark | last post by:
Hello, Can anyone help me on how to find and replace text within a .txt file using vb.net? Any help would be greatly appreciated! Thanks in advance.
0
by: Xah Lee | last post by:
Interactive Find and Replace String Patterns on Multiple Files Xah Lee, 2006-06 Suppose you need to do find and replace of a string pattern, for all files in a directory. However, you do not...
6
by: DataSmash | last post by:
Hello, I need to search and replace 4 words in a text file. Below is my attempt at it, but this code appends a copy of the text file within itself 4 times. Can someone help me out. Thanks! #...
2
by: rengask | last post by:
I got the code to find and replace within an open text file. ------------------ Private Sub cmdFile_Click() Dim strTemp As String txtFile = "" dlg.FileName = "*.*" dlg.ShowOpen ...
3
by: mouac01 | last post by:
Newbie here. How do I do a find and replace in a binary file? I need to read in a binary file then replace a string "ABC" with another string "XYZ" then write to a new file. Find string is the...
2
by: Slippy27 | last post by:
I'm trying to modify a find/replace script which iterates through a file A and makes replacements defined in a csv file B. My original goal was to change any line in file A containing a search string...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.