• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 257
  • Last Modified:

Variable name starting with number

I have an XMLRPC server response with a structure. This structure contains a variable which starts with a number at the beginning (for example, <name> 3stooges </name><value><String>John</String></value>).

When i try to declare the variable with 'legal' syntax (for exaple, threeStuges), the XMLRPC library (CookComputing library at XML-PRC.net) throws an exception saying that it can't find the variable with exact name as is in the XMLRPC response.

My experience is that to properly receive the XMLRPC response, i need to define EXACT structure of the response on the VB .Net (on VS2005). I had several XMLRPC calls properly working when i define exact structures. However, this particular structure is throwing exception as i can not define a variable that starts with a number.

How do i get around this issue of defining a variable (string) that starts with a number. Any help will be greatly appreciated.
0
my_Qn
Asked:
my_Qn
  • 2
1 Solution
 
ladarlingCommented:
You will most likely need to investigate and request help from the XML source provider. None of the mainstream programming languages will allow you to begin a variable name with a number literal. (C++, C#, VB, Java, among others), as I am sure you already know.
Having a transaction that requires an illegally formed structure variable pretty much 'breaks' support for those languages. If the provider wants to expose their data to the programming world at large, they need to change it to respect naming rules.
 
0
 
my_QnAuthor Commented:
Thanks.

Its not going to be feasible to change the XMLRPC service provider as this service is used by several VC++ 6.0 applications successfully. To my surprise, VC++ 6.0 did allow me to declare the CString to begin with a number...

0
 
Anurag ThakurTechnical ManagerCommented:
if i look at your xml returned from your XMLRPC
<name> 3stooges </name><value><String>John</String></value>
3stooges is not a variable
the variable was name and 3stooges was the value of name

if we have a property as defined below
public string name
{
   get { return m_Name; }
   set { m_Name = value; }
}

when we serliaze the  C# object to XML and that class contains the above given property then it will be serialized as below
<ClassName><name>Value what is assigned to name</name></ClassName>
0
 
my_QnAuthor Commented:
Thanks. But the 3stooges IS the variable name.

I figured a way to get around this problem. CookComputing XMLRPC library (www.xml-rpc.net) gives an solution for such issues. It has a built-in XmlRpcResponseStruct that can be used to receive any type of response from the server. We can programatically parse this struct with key and get the value of the parameter.

Its syntax appears as follows

Dim threeStooges as String = myXmlRpcResponseStruct.Items("3stooges")

This dumps the value of 3stooges from the xmlrpc server response in to the variable threeStooges.

It took a lot of trail and error investgation, but now things work as expected.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now