Need Simple way to access XML in VB.Net - Pain with Linq-to-Xml
Dim myXDoc As XDocument = _
I want to access this in a simple way in VB.Net - Like:
Dim Integer SizeXStr = CInt(MyZDoc.Cameras(1).Camera_Desc.@SizeX) ' where (1) is an index
Why isn't this 开发者_运维问答implemented in VB.Net? Better yet, type the values with a Schema and eliminate the conversion. Is this so hard?
How do I access, in a simple way, data in XML - this would be VERY VERY useful!
I have been using Query to try to get the values - when I use MsgBox() to display results, they display, but my main Windows Form is Trashed - changed colors, etc. The system has Bugs.
Instead, I have to create an elaborate structure of arrays of objects and read the XML line-by-line and do the same for saving - this is the dark ages.
Art
I'm not sure of your problem but you're probably missing a .ToString() in there somewhere that MsgBox is implicitly calling for you. Turn Option Explicit
and Option Strict
on fix those (and other) problems. Anyway Given the following variable(VB 2008):
Dim myXDoc = <cameras>
<camera>
<description SizeX="10"/>
</camera>
<camera>
<description SizeX="12"/>
</camera>
</cameras>
You can get an integer using:
Dim SizeX = Integer.Parse(myXDoc.<camera>(0).<description>.@SizeX)
XPathExpression and/or XPathNavigator?
精彩评论