Solved

Variable name starting with number

Posted on 2008-10-07
4
237 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help with error when uploading excel file 3 29
start a process from a service 3 23
SQL Help 27 46
Get distinct values from excel or comm seperated file 4 27
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

831 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