Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

XML encoding < and >

Posted on 2004-08-24
2
Medium Priority
?
7,870 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

636 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