472,977 Members | 2,084 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,977 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 4815
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...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.