[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

read XML from local variable in VB.NET

Posted on 2010-11-24
4
Medium Priority
?
836 Views
Last Modified: 2012-05-10
Hi,

I have a RFID application who connect to a RFID controller and get the tag as they are red by the antennas. Packets is received as bytes and after conversion, the data portion of the packet is XML. I put the result in a string variable. On Quick Watch (Visual Studio), it gives:

"<?xml version='1.0'?>
<Matrics><EventGroup><EventList><Tag event='2' raw='000000000000000000000002' PC='3000' time='4ced7e36' RPL='3'/>
</EventList>
</EventGroup>
</Matrics>

I need to get the tag values from this variable. I've never done any XML before.
I tried:

Dim test As String = ""
Dim Packet As Byte() = Nothing

ReDim Packet(TotalBytes - 1)
Dim j As Integer = 0
For i As Integer = 8 To TotalBytes - 3
      Packet(j) = Data(i)
      j += 1
Next

test = tcpXR450.BytestoString(Packet)

Dim XMLcmd As New XmlDocument
XMLcmd.Load(test)    -----> THIS LINE CRASH with exception: "Illegal characters in path."

How can I get the values from the tag in this XML variable?

thanks for your help
0
Comment
Question by:Dominic34
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 800 total points
ID: 34209140
The Load() method of the XmlDocument class expects a file path as an argument. Use the LoadXml() method instead:

    XMLcmd.LoadXml(test)
0
 
LVL 36

Accepted Solution

by:
Miguel Oz earned 1200 total points
ID: 34209194
test = tcpXR450.BytestoString(Packet)
Dim XMLcmd As New XmlDocument
XMLcmd.LoadXml(test)

Check:
http://www.java2s.com/Code/VB/XML/ConstructXMLdocumentfromString.htm
0
 

Author Comment

by:Dominic34
ID: 34213089
Ok, I changed to LoadXML.

I don't understand the following error I get:
'.', hexadecimal value 0x00, is an invalid character. Line 5, position 1.

Variable in Quick Watch give:
"<Matrics><EventGroup><EventList><Tag event='2' raw='000000000000000000000002' PC='3000' time='4cee87d4' RPL='3'/>
</EventList>
</EventGroup>
</Matrics>

thanks for your help
0
 

Author Comment

by:Dominic34
ID: 34213984
ok, figured it out. My array of bytes had 0x00 filled at the end. I trimmed those NULL caracters by doing a ReDim Preserve of the array, at the correct size, and it works fine now.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

649 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