473,382 Members | 1,425 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

how should this work ?? ( XML )

Hello ,,,

i am currently bussy to learn some XML parsing however i have a slight
problem with it :-)

in the below code i would expect the msgbox to give the result 0201 however
it returns an empty value

how should i handle this ???

( tryed all sorts of combinations with nodes and elements and attributes but
i do not get any values ..... aaaahrghhhh ;-) )



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim x As String = "<?xml version=""1.0"" encoding=""iso-8859-1""?>" & vbCrLf
& _

"<tirep>" & vbCrLf & "<request>" & vbCrLf & "<cmd>0201</cmd>" & vbCrLf &
"<dsc>VS_GetBrands</dsc>" & vbCrLf & _

"<maxcount>200</maxcount>" & vbCrLf & "<IDsOnly></IDsOnly>" & vbCrLf &
"</request>" & vbCrLf & _

"<params>" & vbCrLf & "<session>{[GUID]}</session>" & vbCrLf &
"<BrandName>Au</BrandName>" & _

vbCrLf & "</params>" & vbCrLf & "</tirep>"

MsgBox(x)

Dim xmldoc As New XmlDocument

xmldoc.LoadXml(x)

With xmldoc.SelectSingleNode("tirep")

MsgBox(.Item("request").Item("cmd").Value)
End With

End Sub




Nov 21 '05 #1
3 1056
Change your code to this:

With xmldoc.SelectSingleNode("tirep")
MsgBox(.Item("request").Item("cmd").firstChild.Val ue)
End With

remember that the text of an element is a child node of that element.
"M. Posseth" <mi*****@nohausystems.nl> wrote in message
news:d0**********@reader08.wxs.nl...
Hello ,,,

i am currently bussy to learn some XML parsing however i have a slight
problem with it :-)

in the below code i would expect the msgbox to give the result 0201
however
it returns an empty value

how should i handle this ???

( tryed all sorts of combinations with nodes and elements and attributes
but
i do not get any values ..... aaaahrghhhh ;-) )



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim x As String = "<?xml version=""1.0"" encoding=""iso-8859-1""?>" &
vbCrLf
& _

"<tirep>" & vbCrLf & "<request>" & vbCrLf & "<cmd>0201</cmd>" & vbCrLf &
"<dsc>VS_GetBrands</dsc>" & vbCrLf & _

"<maxcount>200</maxcount>" & vbCrLf & "<IDsOnly></IDsOnly>" & vbCrLf &
"</request>" & vbCrLf & _

"<params>" & vbCrLf & "<session>{[GUID]}</session>" & vbCrLf &
"<BrandName>Au</BrandName>" & _

vbCrLf & "</params>" & vbCrLf & "</tirep>"

MsgBox(x)

Dim xmldoc As New XmlDocument

xmldoc.LoadXml(x)

With xmldoc.SelectSingleNode("tirep")

MsgBox(.Item("request").Item("cmd").Value)
End With

End Sub



Nov 21 '05 #2
Thanks ,,,

This worked great !

i also found this alternative method

MsgBox(xmldoc.GetElementsByTagName("cmd").Item(0). InnerText)

wich gives me the same result however , i do not trust this method as much
as i do yours :-)

again thanks for your help

Michel

"Scott M." <s-***@nospam.nospam> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Change your code to this:

With xmldoc.SelectSingleNode("tirep")
MsgBox(.Item("request").Item("cmd").firstChild.Val ue)
End With

remember that the text of an element is a child node of that element.
"M. Posseth" <mi*****@nohausystems.nl> wrote in message
news:d0**********@reader08.wxs.nl...
Hello ,,,

i am currently bussy to learn some XML parsing however i have a slight
problem with it :-)

in the below code i would expect the msgbox to give the result 0201
however
it returns an empty value

how should i handle this ???

( tryed all sorts of combinations with nodes and elements and attributes
but
i do not get any values ..... aaaahrghhhh ;-) )



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim x As String = "<?xml version=""1.0"" encoding=""iso-8859-1""?>" &
vbCrLf
& _

"<tirep>" & vbCrLf & "<request>" & vbCrLf & "<cmd>0201</cmd>" & vbCrLf &
"<dsc>VS_GetBrands</dsc>" & vbCrLf & _

"<maxcount>200</maxcount>" & vbCrLf & "<IDsOnly></IDsOnly>" & vbCrLf &
"</request>" & vbCrLf & _

"<params>" & vbCrLf & "<session>{[GUID]}</session>" & vbCrLf &
"<BrandName>Au</BrandName>" & _

vbCrLf & "</params>" & vbCrLf & "</tirep>"

MsgBox(x)

Dim xmldoc As New XmlDocument

xmldoc.LoadXml(x)

With xmldoc.SelectSingleNode("tirep")

MsgBox(.Item("request").Item("cmd").Value)
End With

End Sub




Nov 21 '05 #3
There are many ways to parse through XML using the W3C DOM and MS's
implementation of its own XML DOM. Just remember that when parsing through
XML, everything is considered a node and you must treat each item as such.
"M. Posseth" <mi*****@nohausystems.nl> wrote in message
news:d0**********@reader08.wxs.nl...
Thanks ,,,

This worked great !

i also found this alternative method

MsgBox(xmldoc.GetElementsByTagName("cmd").Item(0). InnerText)

wich gives me the same result however , i do not trust this method as much
as i do yours :-)

again thanks for your help

Michel

"Scott M." <s-***@nospam.nospam> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Change your code to this:

With xmldoc.SelectSingleNode("tirep")
MsgBox(.Item("request").Item("cmd").firstChild.Val ue)
End With

remember that the text of an element is a child node of that element.
"M. Posseth" <mi*****@nohausystems.nl> wrote in message
news:d0**********@reader08.wxs.nl...
> Hello ,,,
>
> i am currently bussy to learn some XML parsing however i have a slight
> problem with it :-)
>
> in the below code i would expect the msgbox to give the result 0201
> however
> it returns an empty value
>
> how should i handle this ???
>
> ( tryed all sorts of combinations with nodes and elements and
> attributes
> but
> i do not get any values ..... aaaahrghhhh ;-) )
>
>
>
>
>
>
>
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
>
> Dim x As String = "<?xml version=""1.0"" encoding=""iso-8859-1""?>" &
> vbCrLf
> & _
>
> "<tirep>" & vbCrLf & "<request>" & vbCrLf & "<cmd>0201</cmd>" & vbCrLf
> &
> "<dsc>VS_GetBrands</dsc>" & vbCrLf & _
>
> "<maxcount>200</maxcount>" & vbCrLf & "<IDsOnly></IDsOnly>" & vbCrLf &
> "</request>" & vbCrLf & _
>
> "<params>" & vbCrLf & "<session>{[GUID]}</session>" & vbCrLf &
> "<BrandName>Au</BrandName>" & _
>
> vbCrLf & "</params>" & vbCrLf & "</tirep>"
>
> MsgBox(x)
>
> Dim xmldoc As New XmlDocument
>
> xmldoc.LoadXml(x)
>
> With xmldoc.SelectSingleNode("tirep")
>
> MsgBox(.Item("request").Item("cmd").Value)
>
>
> End With
>
> End Sub
>
>
>
>
>
>
>
>
>
>



Nov 21 '05 #4

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

Similar topics

2
by: Venkat | last post by:
Hi, My HTML page doesnot work properly in Netscape 7.1. But works fine in Opera 7 and IE 6.0. I could not figure out the problem. If any one could/suggest it would be nice.. This piece of HTML...
2
by: Andrew Mogford | last post by:
Hi, We have moved a web site from a development server running Windows 2000 and IIS 5 to a Windows 2003 server running IIS 6.0 Now the asp pages do not work correctly. For example,...
0
by: Jarod_24 | last post by:
How does tabindex work in ASP .net pages I dosen't seem to work quite like in regular forms. and there isn't any TabStop property either. 1 .How do you prevent a control form beign "tabbed"....
30
by: bblais | last post by:
Hello, Let me start by saying that I am coming from a background using Matlab (or Octave), and C++. I am going to outline the basic nuts-and-bolts of how I work in these languages, and ask for...
4
by: rodchar | last post by:
hey all, i working with the Publisher object model in an ASP.NET page. When I'm working with my project locally everything works fine. However, when I deploy the application to my app server, it...
9
by: Cliff | last post by:
I've got a number of SNMP devices scattered around the globe that I want to get some information off.. I've got a couple of classes whcih get a quite complex table together from SQL and SNMP...
3
by: hscott93 | last post by:
Hello. I have a new Vista based laptop at work that connects to a Windows 2003 Small Business Server at work via an assigned, static IP address. When I take the laptop home, I have router that...
2
by: gsherp | last post by:
I can get the Onclick event handler to work when I added a new row using insertRow. It doesn't work in IE or in FF var cellarea = row.insertCell(2); cellarea.style.backgroundColor =...
0
by: wimdows | last post by:
Hi, I've successfully added custom fields to the Task Work Item template, using the Process Editor (and opening from server). However, I would like to also see these items in the field list...
1
by: FlashT | last post by:
Hello, I got a script: http://www.mattkruse.com/javascript/autocomplete/index.html It works fine on IE and Opera, but does not on FF. It does something on FF, but not what it should do (check...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.