?
Solved

XML encoding < and >

Posted on 2004-08-24
2
Medium Priority
?
7,866 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 1000 total points
ID: 11880626
Are you able to use Replace() ?

Something like:

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


0
 

Author Comment

by:ieg
ID: 11881738
Carl,
This worked a treat.

Thanks very much

Andy
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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, …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

765 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