Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jul 15, 2009 04:51 PM by pauldj54
Oct 03, 2006 06:02 PM|LINK
I have an xml string:
which I need to be able to parse and retrieve the elements from.
So, newbie question... does anyone have a sample of code that i can use where I pass the xml string as a parameter and then can access each element programatically:
intResponse = parm("RESPONSE")
or some such thing...
Oct 03, 2006 08:09 PM|LINK
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
System.Xml.XmlNode element = doc.SelectSingleNode("/AUTHRESP/RESPONSE");
Oct 03, 2006 08:57 PM|LINK
I like that.
Easy to understand, very exacting to my needs (my XML string after all), a thing of beauty![:D]
Oct 04, 2006 01:09 PM|LINK
I have tried to create the VB version of this but I have missed something, no errors, just incorrect results. Here is the result information I get
Raw xml: <?xml version="1.0"?><AUTHRESP><RESPONSE>0</RESPONSE><AUTHPARM1>S980999999</AUTHPARM1><BALLOT>1</BALLOT></AUTHRESP>
Results: AuthParm1 =
Ballot Type: 0
and here is the code I used to get it:
Dim thisResult As
Dim xmlDoc As
thisResult.ConditionCode = xmlDoc.SelectSingleNode("/AUTHRESP/RESPONSE").Value
thisResult.AuthParm1 = xmlDoc.SelectSingleNode("/AUTHRESP/AUTHPARM1").Value
thisResult.BallotType = xmlDoc.SelectSingleNode("/AUTHRESP/BALLOT").Value
If Debug = True
EventLog.WriteEntry(Me.ServiceName & ".fnParseAuthenticationResp" & vbCrLf & "Raw xml: " & XML & vbCrLf & "Results: AuthParm1 =" & thisResult.AuthParm1 & vbCrLf & "Ballot Type: " & thisResult.BallotType
& vbCrLf & "ConditionCode: " & thisResult.ConditionCode, EventLogEntryType.Information)
Can you see where I am going wrong here? I don't seem to be retrieving the values.
Oct 04, 2006 01:36 PM|LINK
Jul 15, 2009 02:41 PM|LINK
If a build the xml document with de xmldocument.loadxml method I cannot specify the DTD, because the XmlDocumentType cannot be added if there's a root element in the document.
I'm sending a string from a web service client running in eclipse and coding with java to a .net web service written in c#, when I build the string from the .xml file in java, the parse method checked the file against the DTD but exclude the <!DOCTYPE header
from the string, so, when I recieved the string in the web service I have to define de DTD again.
Any ideas about this issue.
Jul 15, 2009 03:43 PM|LINK
Maybe I am not understanding, what exactly is it you are trying to do?
Jul 15, 2009 04:51 PM|LINK
I have a Web Service written in c# a published using visual studio 2008.
The ws has a webmethod that recieved 3 xml files and 1 txt file as arguments.
I have to make a client in java with eclipse, so, I installed the axis plugin. This plugin generates the proxy classes usin the WSDL of the .net ws
My first problem was how to interoperate between java and c# because the Xmldocument type in c# is slightly different to the Document type in Java. I decided to change the webmethod to recieved strings instead of xml and text files. Then I wrote a code in
java to convert a xml document into a string and there's no problem with the interoperability of the simple types.
I found a problem parsing the xml files into strings, the java methods use the dtd to build the strings but the <!DOCTYPE XMI SYSTEM "UML_EA.dtd"> was not inserted in the string.
In the ws I recieved each string and converting them into xml files again. The files are the same as the original ones but without the DTD declaration, which is a problem because if I want to search a tag element by an ID, since I'm not defining a dtd the
program does not know what an Id is.
Finally a use a non elegant trick, I took each string as I recieved them and then insert the <!DOCTYPE XMI SYSTEM "UML_EA.dtd"> with the string.insert method and now it's working.
I'm learning a lot with this project but I don't have enough time to do an elegant or brilliant implementation because the deadlines are comming for me jejejej