Solved

XML encoding < and >

Posted on 2004-08-24
2
7,857 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 250 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP.NET reading ATOM 2 79
Automating receiving uploaded files via HTTPS instead of SFTP 3 112
xml with php question 5 53
ASP Classic - Read XML File inner content 10 72
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, …

734 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