Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Inserting Value in XML
#2
Solved: 10 Years, 9 Months ago
A couple of things are wrong here. First, Writeline is a function of the Scripting.FileSystemObject so you can't just call that function without its associated object. To concatenate strings to a variable in VBScript, you simply have to say var = var & "more string". Also, to get quotes in VBScript you simply have to type two together. If you are trying to get soapenv="" in your output, you have to double the quotes in the string constant "soapenv="""">". Seems silly, but that's how it works.

Code:
Dim rackNm, Input_request

rackNm = Array(1, 2, 3, 4, 5)

Input_request = "<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"">" & _
"<soapenv:Header />" & _
"<soapenv:Body>" & _
"<rm:itemSouring>" & _
"<rm:itemNames>"

For Each x In rackNm
Input_request = Input_request & "<rm:item>" & x & "</rm:item>"
Next

Input_request = Input_request & "</rm:itemNames>" & _
"</rm:itemSouring>" & _
"</soapenv:Body>" & _
"</soapenv:Envelope>"

MsgBox Input_request

If you are wanting to add the new line character to make the formatting look decent, then you might try something like this:

Code:
Dim rackNm, Input_request

rackNm = Array(1, 2, 3, 4, 5)

Input_request = "<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"">" & vbNewLine & _
vbTab & "<soapenv:Header />" & vbNewLine & _
vbTab & "<soapenv:Body>" & vbNewLine & _
vbTab & vbTab & "<rm:itemSouring>" & vbNewLine & _
vbTab & vbTab & vbTab & "<rm:itemNames>" & vbNewLine

For Each x In rackNm
Input_request = Input_request & vbTab & vbTab & vbTab & vbTab & "<rm:item>" & x & "</rm:item>" & vbNewLine
Next

Input_request = Input_request & vbTab & vbTab & vbTab & "</rm:itemNames>" & vbNewLine & _
vbTab & vbTab & "</rm:itemSouring>" & vbNewLine & _
vbTab & "</soapenv:Body>" & vbNewLine & _
"</soapenv:Envelope>"

MsgBox Input_request

Kind of messy, but it does the job.
Reply


Messages In This Thread
Inserting Value in XML - by newinqtp - 10-28-2010, 02:25 PM
RE: Inserting Value in XML - by cdesserich - 11-01-2010, 11:32 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Inserting variable values into Descriptive Programming Functions eske99 2 3,146 12-18-2015, 01:47 PM
Last Post: vinod123
  Getting an 'Error in XML document' Error when submitting web services XML luckyexpert 0 2,940 08-20-2013, 10:23 PM
Last Post: luckyexpert
  Inserting Images in the Word file. atulparate 2 6,424 04-09-2012, 12:44 PM
Last Post: swathi
  Need URGENT help how to read xml string / xml tag value in web page using QTP VQTP 2 5,707 04-16-2009, 02:27 AM
Last Post: VQTP

Forum Jump:


Users browsing this thread: 1 Guest(s)