473,804 Members | 2,123 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Parsing XML

Thank you in advance for any and all assistance. It is greatly appreciated.

I am working with Plimus for licensing my software. I can communicate with
the server and I'm getting responses in XML. My question is, the XML stream
that's coming back is telling if it's a successful license registration,
validation, too many installs etc. How do I capture that information and use
in my logic?

I tried:
'If responseContent = "<status>STATUS _CODE</status>" Then

' MessageBox.Show ("The key you have enter is either invalid
or you misentered the key. Please try again")
' License.Text = ""
' License.Focus()
'Else
MessageBox.Show (responseConten t)
'MessageBox.Sho w("Thank you for registering. Enjoy your
software!")
'Me.Close()
'Dim frm As Form
'frm = frmEZTechToolsI dentifier
'frm.Show()

but the code doesn't capture the XML stream. What do I need please?

--
Michael Bragg, President
eSolTec, Inc.
a 501(C)(3) organization
MS Authorized MAR
looking for used laptops for developmentally disabled.
Sep 12 '06 #1
4 2018
=?Utf-8?B?ZVNvbFRlYyw gSW5jLiA1MDEoYy koMyk=?= <es*****@noemai l.nospam>
wrote in news:B5******** *************** ***********@mic rosoft.com:
I tried:
'If responseContent = "<status>STATUS _CODE</status>" Then
Perhaps more data than that is coming back.
>
but the code doesn't capture the XML stream. What do I need please?
Take a look at the System.Text.XML classes - you should load the entire doc
into one of the XML class structures (XML Doc, XML reader, etc) and use
those classes to parse the response. You'll get a more accurate result than
merely text parsing.
Sep 13 '06 #2
Hello Michael,

As for the XML Response stream, how did you get it, through HttpWebRequest
compoent or any other means? Also, before you want to parse the XML
response content, where did you hold the XML content? In a string or a
inmemory stream?

In .net framework, most of the XML processing classes are under the
System.Xml namespace. And you can choose the proper class to maniplate XML
content depend on the format of data you hold. Here are some general
suggestions:

1. If the resposne XML content is held in a string, you can use the
XmlDocument class's "LoadXml" to load it.

#XmlDocument.Lo adXml Method
http://msdn2.microsoft.com/en-us/lib...t.loadxml.aspx

2. If the response XML content is in an Stream object (memorystream,
HttpResponseStr eam....), you can use the XmlDocument.Loa d method to load it
into XmlDocument.

After you have load the XML content into XmlDocument instance, you can use
its "SelectSingleNo de" or "SelectNode s" method to query specific nodes
(through XPATH string) from it and check the certain node's value.

#Select Nodes Using XPath Navigation
http://msdn2.microsoft.com/en-us/library/d271ytdx.aspx

#XML Document Object Model (DOM)
http://msdn2.microsoft.com/en-us/library/hf9hbf87.aspx

For more information about processing XML data in .net framework, you can
refer to the following MSDN reference:

#XML Documents and Data
http://msdn2.microsoft.com/en-us/library/2bcctyt8.aspx
Please feel free to let me know if you have any further specific questions
on this.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

=============== =============== =============== =====

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.


Sep 13 '06 #3
Thank you for your response. The XML is streamed into a string I believe and
I can give you all the code that's used and that is being returned.
<plimus_licensi ng_response><st atus>ERROR_MAXC OUNT</status><days_si nce_last_assign ed>1</days_since_last _assigned><days _till_expiratio n>358</days_till_expir ation><use_coun t>1</use_count></plimus_licensin g_response>

This is the string information that is returned from the license company.
The part that I need to parse and run logic on is the
<status>ERROR_C ODE</status>

Based on the error_code, I need to build the IF Then Else statement to make
the code either open the program, return a message to the user, close the
program and refer the user to the support website.

Here is the code I'm using to return the values.

If Username.Text = "" And eMail.Text = "" And tbxLicense.Text = "" Then
MessageBox.Show ("Please enter your registered name.")
Username.Focus( )
ElseIf Username.Text <"" And eMail.Text = "" And tbxLicense.Text =
"" Then
MessageBox.Show ("Please enter the person's email for this
computer")
eMail.Focus()
ElseIf Username.Text <"" And eMail.Text <"" And tbxLicense.Text
= "" Then
MessageBox.Show ("Please enter the license number:
###-####-####-####")
tbxLicense.Focu s()
Else
Dim request As Net.HttpWebRequ est
Dim response As Net.HttpWebResp onse
Dim url As String =
"https://www.plimus.com/jsp/validateKey.jsp ?action=REGISTE R&productId=### ##&key="
& tbxLicense.Text & "&action=REGIST ER &uniqueMachineI d&=" & GetOSProductKey ()
& eMail.Text & Username.Text
request = Net.WebRequest. Create(url)
request.Method = "Get"
response = request.GetResp onse()
Dim sr As IO.StreamReader = New
IO.StreamReader (response.GetRe sponseStream())
Dim responseContent As String = sr.ReadToEnd()

sr.Close()
response.Close( )
Dim reader As Xml.XmlTextRead er = Nothing
tbxResponseCont ent.Text = responseContent

I've looked at code samples and have started with the Dim reader as
Xml.XmlTextRead er = Nothing

The XML response is currently returned to a textbox called
tbxResponseCont ent.Text. The XML stream is the responseContent .
--
Michael Bragg, President
eSolTec, Inc.
a 501(C)(3) organization
MS Authorized MAR
looking for used laptops for developmentally disabled.
"Spam Catcher" wrote:
=?Utf-8?B?ZVNvbFRlYyw gSW5jLiA1MDEoYy koMyk=?= <es*****@noemai l.nospam>
wrote in news:B5******** *************** ***********@mic rosoft.com:
I tried:
'If responseContent = "<status>STATUS _CODE</status>" Then

Perhaps more data than that is coming back.

but the code doesn't capture the XML stream. What do I need please?

Take a look at the System.Text.XML classes - you should load the entire doc
into one of the XML class structures (XML Doc, XML reader, etc) and use
those classes to parse the response. You'll get a more accurate result than
merely text parsing.
Sep 13 '06 #4
Thanks for your reply Michael,

For the xml fragment you provide, you can simply use XPATH to query out the
<statuselemen t and its innerTEXT data. For example, the following code
use xmlDocument to load the xml data from string, and use the
SelectSingleNod e to query the node throug XPATH string:

=============== =============== ===
Dim xmlstring =
"<plimus_licens ing_response><s tatus>ERROR_MAX COUNT</status><days_si nce_last_
assigned>1</days_since_last _assigned><days _till_expiratio n>358</days_till_ex
piration><use_c ount>1</use_count></plimus_licensin g_response>"

Dim doc As New System.Xml.XmlD ocument

doc.LoadXml(xml string)

Dim node As XmlNode

node = doc.SelectSingl eNode("/plimus_licensin g_response/status")

If Not node Is Nothing Then
Response.Write( "<br/>status: " & node.InnerText)
End If
=============== =============== =====
BTW, the above xpath string only suit this particular case, for other xml
fragment, you need to calculate the proper xpath when you want to query
other node or nodelist.

Here are some articles introducing XPATH and xpath query in .net framework
XML components:

#XPath Tutorial
http://www.w3schools.com/xpath/

#XPath Selections and Custom Functions, and More
http://msdn.microsoft.com/msdnmag/is...3/02/XMLFiles/

#.NET and XML: XPath Queries
http://www.developer.com/net/net/article.php/3383961

Hope this also helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.


Sep 14 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
9449
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $ Last-Modified: $Date: 2003/10/28 19:48:44 $ Author: A.M. Kuchling <amk@amk.ca> Status: Draft Type: Standards Track
2
3962
by: Cigdem | last post by:
Hello, I am trying to parse the XML files that the user selects(XML files are on anoher OS400 system called "wkdis3"). But i am permenantly getting that error: Directory0: \\wkdis3\ROOT\home Canonicalpath-Directory4: \\wkdis3\ROOT\home\bwe\ You selected the file named AAA.XML getXmlAlgorithmDocument(): IOException Not logged in
16
2911
by: Terry | last post by:
Hi, This is a newbie's question. I want to preload 4 images and only when all 4 images has been loaded into browser's cache, I want to start a slideshow() function. If images are not completed loaded into cache, the slideshow doesn't look very nice. I am not sure how/when to call the slideshow() function to make sure it starts after the preload has been completed.
0
4133
by: Pentti | last post by:
Can anyone help to understand why re-parsing occurs on a remote database (using database links), even though we are using a prepared statement on the local database: Scenario: ======== We have an schema (s1) on an Oracle 9i database with database links pointing to a schema (s2) on another Oracle 9i database.
9
4065
by: ankitdesai | last post by:
I would like to parse a couple of tables within an individual player's SHTML page. For example, I would like to get the "Actual Pitching Statistics" and the "Translated Pitching Statistics" portions of Babe Ruth page (http://www.baseballprospectus.com/dt/ruthba01.shtml) and store that info in a CSV file. Also, I would like to do this for numerous players whose IDs I have stored in a text file (e.g.: cobbty01, ruthba01, speaktr01, etc.)....
5
4311
by: randy | last post by:
Can some point me to a good example of parsing XML using C# 2.0? Thanks
3
4390
by: toton | last post by:
Hi, I have some ascii files, which are having some formatted text. I want to read some section only from the total file. For that what I am doing is indexing the sections (denoted by .START in the file) with the location. And for a particular section I parse only that section. The file is something like, .... DATAS
13
4529
by: Chris Carlen | last post by:
Hi: Having completed enough serial driver code for a TMS320F2812 microcontroller to talk to a terminal, I am now trying different approaches to command interpretation. I have a very simple command set consisting of several single letter commands which take no arguments. A few additional single letter commands take arguments:
7
2413
by: Daniel Fetchinson | last post by:
Many times a more user friendly date format is convenient than the pure date and time. For example for a date that is yesterday I would like to see "yesterday" instead of the date itself. And for a date that was 2 days ago I would like to see "2 days ago" but for something that was 4 days ago I would like to see the actual date. This is often seen in web applications, I'm sure you all know what I'm talking about. I'm guessing this...
1
4411
by: eyeore | last post by:
Hello everyone my String reverse code works but my professor wants me to use pop top push or Stack code and parsing code could you please teach me how to make this code work with pop top push or Stack code and parsing code my professor i does not like me using buffer reader on my code and my professor did even give me an example code for parsing as well as pop push top or Stack code and i don't know how to do this code into parsing and pop push...
0
9715
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9595
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10097
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7642
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6867
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5535
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3835
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.