Solved

Variable name starting with number

Posted on 2008-10-07
4
235 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now