Solved

XML encoding < and >

Posted on 2004-08-24
2
7,847 Views
Last Modified: 2012-05-05
I have and XML document that has been built up as a string (using VBScript) see below

Dim XMLIn
XMLIn = "<?xml version=""1.0"" encoding=""Windows-1252""?>" & _
                "<Query xmlns:xsd=""http://www.w3.org/2000/10/XMLSchema-instance"" xsd:noNamespaceSchemaLocation=""INVQRY.XSD"">" & _
      "<Key>" & _
      "<StockCode>BCS100</StockCode>" & _
      "</Key>" & _
      "</Query>"

What I need to do is convert this so that all the "<" and ">" are replaced by &lt; and &gt;
The reason for this is that this string needs to passed in a SOAP message to a webservice. If the < and > are present then SOAP tries to interpret the XML as commands to SOAP and fails.

Can anyone recommend a control that would encode the string for me?

Regards

Andy
0
Comment
Question by:ieg
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 250 total points
Comment Utility
Are you able to use Replace() ?

Something like:

    XMLIn = Replace(XMLIn, "<", "&lt;")
    XMLIn = Replace(XMLIn, ">", &gt;")


0
 

Author Comment

by:ieg
Comment Utility
Carl,
This worked a treat.

Thanks very much

Andy
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now