|
Hi,
I am new to XML and C#. I want to load this XML via the below code to an XmlDocument but it returns an Error which I don't know how to handle it. Here is the XML:
<?xml version="1.0" encoding="UTF-8"?>
<epp xmlns="urn:iana:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:iana:xml:ns:epp-1.0 epp-1.0.xsd">
<response>
<result code="1000">
<msg lang="en-US">Command completed successfully</msg>
</result>
<resData>
<contact:creData>
<contact:id>Epp1464</contact:id>
</contact:creData>
</resData>
<trID>
<clTRID>CrtContact0031</clTRID>
<svTRID>CrtContact0031-OLNIC-SRV</svTRID>
</trID>
<chksum>979170f7c148e945e352c7d155da8ac2</chksum>
</response>
</epp>
And here is my code. Actually I need also to know how to get the <contact:id> and <result> node bvalue and attribue.
try
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(strXMLSrc);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
Please help.
Samy
-- modified at 8:35 Wednesday 11th January, 2006
|
|
|
|
|
Please always include the error - saves the rest of us from running it so see the problem.
You are missing a namespace decleration for "contact".
If you do not know how XML namespaces work, you can for example look here:
http://www.w3schools.com/xml/xml_namespaces.asp[^]
|
|
|
|
|
Hi,
I am so sorry. Here si the error.
'contact' is an undeclared namespace. Line 8, position 2.
As It shows the namespace is not defined.
But the XML is generated by a server and I can't change the strcuture. Therefore How can I bypass this error checking.
Regards,
Samy
|
|
|
|
|
What's the error message?
|
|
|
|
|
Hi,
I am so sorry. Here si the error.
'contact' is an undeclared namespace. Line 8, position 2.
As It shows the namespace is not defined.
But the XML is generated by a server and I can't change the strcuture. Therefore How can I bypass this error checking.
Regards,
Samy
|
|
|
|
|
Hi,
What is the difference between .parse and casting?
Is it true that in every case that you use .parse you can use casting instead?
Thanks
|
|
|
|
|
Parse will try to convert a value into another one, whereas casting will convert the bits in a way the compiler thinks it should be correct.
Casting a long to an int might cause loss of data. If you're lucky the compiler will give you a warning at compile time.
The Parse method will throw an exception at runtime if the parsing fails. You should use Parse when converting data entered by a user, e.g. to check if the text entered into a textbox is a double value.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
And, don't forget the TryParse variants that don't throw exceptions.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Parsing takes a string and tries to interpret it as a value, for an example a number or a date.
Casting will either tell the compiler to handle an object as a specific type, or transform a data type to a similar data type.
For an example, you can cast a string into the type Object (as String inherits from Object), then cast it back to the type String.
You can safely cast to a type with higher precision, like from an int to a long. You can also cast to a lower presicion type, like from a long to an int, but that will cause an exception if the value is to large.
You can't use casting instead of parsing. For an example you can't cast a string to an int.
---
b { font-weight: normal; }
-- modified at 17:18 Wednesday 11th January, 2006
|
|
|
|
|
Hi gurus,
I'd like to know how to get the IPv4 address of the current host in .NET 2?
Thanks.
Best regards.
Fred.
There is no spoon.
|
|
|
|
|
it is like ipv6= 0.0.ipv4
Mikail Çetinkaya . The C# DEveloper
|
|
|
|
|
Whatever that means... and no, that's not how an IP6 address looks. You didn't even tell him how to resolve the name, let alone find the name of the machine.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
You could get the host name from the DNS.GetHostName[^] method, then pass that name to the Dns.GetHostAddresses[^] method to retrieve all the IP addresses known for this host.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
yes, I know, this is shown in the msdn, but how to get the right address? That is the one which appears in the properties pannel of the network connection...
fred.
There is no spoon.
|
|
|
|
|
There is no "right-address". A single NIC can have multiple addresses assigned to it. This is the address that DNS servers know about.
You could also get this from WMI (System.Management namespace). All you need to do is search for all the occurances of Win32_NetworkAdapterConfiguration objects. Each will have its own array of IPAddresses. Warning: You might be surprised at how many of these object and addresses there really are! Once you have those, examine them to see which ones have an active DefaultIPGateway. This will be the adapter and set of addresses that your talking about.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello,
I am trying to develop a simple application in dot net for the use of FUS-200N finger print scanner. I had downloaded quite a few samples but they fail to detect the scanner! I am writing code in C#. The earlier sample code is in VB6.0 and it runs fine. but due to incompatiblility I am not able to use those vb6 dll's as such in dot net.
Since I am developing this application for local use, i cannot afford the aid SDK's.
The VB6 application of mine is able to read from this scanner but I am unable to do this in the dot net (C#) environment.
I have to convert this funtion of vb6 to c#
Declare Function VFPSinit Lib "VFPSImg.dll" _
(ByVal sensorID As Long, _
ByRef numRows As Long, _
ByRef numCols As Long, _
ByRef mode As Long, _
ByVal configFile As Any, _
ByVal flags As Long, _
usrBkgndImage As Any, _
callBackFcn As Any _
) As Long
Question#1>>>>>
In C#, what is the meaning substitute of 'any' ??
also, it is being called like
"sensorHandle = VFPSinit(sensorID, numRows, numCols, 0&, 0&, flags, 0&, 0&)"
Question#2>>>>> What is 0& ? in vb6, how do i convert it to C# code ?
Following is my C# code...
Since I cannot call this dll directly as the IDE doesn't let me add it as a reference, I am using the P/Invoke.
// 1., To call the dll, following is the code
[ DllImport( "VFPSimg.dll")]
//Function #2
public static extern int VFPSinit(object sensorID, object numRows,
object numCols, object mode, object configFile,
long flags,object usrBkgndImage,object callBackFcn);
// 2., To call the function, following is the code
sensorHandle = ComFunc.VFPSinit(sensorID, numRows, numCols, 0, 0, flags, 0, 0);
After the above call, in the original VB6 code, I would succesfully get the numrows and numcols updated as they are sent via refernce, and the scanner sensorHandle would also be updated. I have even tried converting all the VB 6.0 long to integers in C# but to no avail.
If anyone ahs any idea about this sort of a thing in C#, and without usinffcommercial products, kindly get back!!
help me.. I am practically at my wits end!!
C.K.
|
|
|
|
|
Ckhurana wrote: Since I am developing this application for local use, i cannot afford the aid SDK's
You just increased your level of difficulty 10 times over. Without the docs, you're pretty much screwed.
Anyway... Any in VB6 ROUGHLY translates to Object in C# and VB.NET. The problem is without seeing the C function header for calling these functions, it's impossible to tell you what the real C# datatype should be and how to pass it.
Ckhurana wrote: Since I cannot call this dll directly as the IDE doesn't let me add it as a reference, I am using the P/Invoke.
It looks as though this is not a COM .DLL you're calling, so no you can't set a reference to it. You have to P/Invoke it, just the the VB code is doing. A closer extern for C# would be (taken from the VB6 code!):
public delegate int CallBack(int whatever);
[ DllImport( "VFPSimg.dll")]
public static extern int VFPSinit(int sensorID, ref int numRows, ref int numCols,
ref int mode, string configFile, int flags, object usrBkgndImage, CallBack func);
int sensorHandle = VFPSinit( sensorID, rows, cols, null, null, flags, null, null);
This code is BY NO MEANS guaranteed to work. Like I keep saying, without the original function headers and documentation, you're just guessing at what you have to pass and how you have to pass it!
For more information on implementing the callback part of this, see this[^] article on MSDN.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have a class myclass{public int a;} and a string str="a".
I want to set myclassobject.a=1 as myclassobject.str=1.How is it possible? }
bidisha
|
|
|
|
|
Your class is:
class myclass
{
public int a;
}
There is no definition of str in your class. You cannot set myclassobject.str = 1;
What is it you actually want to do? To what purpose do you want to set str=1 in a class that contains no definition of str ?
Also, on a matter of coding guides, you should not make fields public like this. You should encapsulate them in a property.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
Actually I have a xsd file from which I autogenerate a .cs file containing all class definations.I need to change my xsd often,so the members of the class often changes.And I want to initialise the members at run time whose name I can specify through a string str.suppose I set str="call".Now I want to set myobject.call=value.Please help.
bidisha
|
|
|
|
|
Then you need to have a look at some of the stuff in the System.Reflection namespace. Start with typeof(MyClass) which returns a Type object and from there you can enumerate all sorts of things like the properties in a class, you can then invoke them in order to set the value of the property and so on.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
I have used FieldInfo.setValue to set the fields where FieldInfo.Name=my_specified_name.
I have no problem with setting the field value with primitive datatype such as string or int.But some field are of user defined datatype.For example, I have a field as
Call mycall;
where
public class Call
{
string calltime;
string callvalue;
}
I cant reach to mycall.calltime using FieldInfo.
bidisha
|
|
|
|
|
I've inserted CheckBoxes to a RichTextBox using RichEditOLE's InsertObject() function. But when i try to check the CheckBox, it selects the CheckBox on the first Click and checking is done only on double clicking the CheckBox. Moreover it takes only MouseDown and Click Event. No other events are handled. Any ideas to solve this?
Linda Thomas
|
|
|
|
|
Hi all
can anyone tell me how to draw a line without flickering the screen
Thanks
Pramod
|
|
|
|
|
In your constructor (of the control that is drawn upon):
base.Setstyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint);
Did this from the top of my head, so maybe the enums are not spelled correctly, but it should point you in the right direction.
Also make sure you do the painting in OnPaint , not GreateGraphics .
HTH!
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick || Fold With Us! || Pensieve || VG.Net ||
|
|
|
|
|