Solved

Variable name starting with number

Posted on 2008-10-07
4
239 Views
Last Modified: 2013-12-17
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
Comment
Question by:my_Qn
  • 2
4 Comments
 
LVL 11

Expert Comment

by:ladarling
ID: 22662900
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
 

Author Comment

by:my_Qn
ID: 22663614
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
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 22670714
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
 

Accepted Solution

by:
my_Qn earned 0 total points
ID: 22670872
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

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display

791 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