home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Join TechIMO for Free!
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Reply Get bargains at  »  Dealighted.com
 
Thread Tools
Currently Active Users: 2488
Discussions: 186,605, Posts: 2,227,028, Members: 230,238
Free Scan: Update Your PC's Outdated Drivers to Optimize Performance
Old September 20th, 2008, 12:01 AM   Digg it!   #1 (permalink)
Member
 
Join Date: Oct 2003
Posts: 247
linq to xml

need help with all you linq experts...

got a simple xml files:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<root>
  <Package id="1" name="Jason1">
    <nuclide rsic="100" nucname="co60"></nuclide>
    <nuclide rsic="110" nucname="co70"></nuclide>
  </Package>
  <Package id="2" name="Jason2">
    <nuclide rsic="200" nucname="do60"></nuclide>
    <nuclide rsic="210" nucname="do70"></nuclide>
  </Package>
</root>
as you can see nuclide is a list of nuclides inside a package...

so i have a package class which contains a list of nuclides...

I want to populate my object from the xml file but i am having trouble with the syntax of loading the list....

This is what i have... I tried a whole bunch of other thing that didnt work...this is the ball park i am in right now:

Code:
        Dim xml As New XmlDocument
        xml.Load("Test.xml")


         Select New MyNewClass() With {._iID = CType(CType(myXML, XmlElement).GetAttribute("id"), Int32), _
                                    ._strName = CType(myXML, XmlElement).GetAttribute("name").ToString} _
                                    .AddNuc = (From myxml2 In xml.ChildNodes(0) Select New Nuclides With {._iID = CType(CType(myxml2, XmlElement).Attributes("rsic").Value, Int32)}).ToArray


i was able to load everything, but it would only load the first nuclide. I can't get it too loop around. It looks like i need another select statement but i can't figure out the syntax. havent found anything on the web yet that resembles this issue.

Thanks in advance

amtrac24 is offline   Reply With Quote
TechIMO.com Ads - Login or register for less ads.
How many errors does your computer have?

You no longer need to guess! This free stability scan and registry cleaner download will give you a complete diagnosis of your Windows registry, identifying errors and conflicts.

FREE instant scan


Guest, Register Free! to remove this ad and get your tech support questions answered in minutes!
Old September 20th, 2008, 12:23 AM     #2 (permalink)
Member
 
Join Date: Oct 2003
Posts: 247
i figured it out

incase anyone wants to know the answer....

Code:
  Dim SQL = From myXML In xml.SelectNodes("root/Package") _
                   Select New MyNewClass() With {._iID = CType(CType(myXML, XmlElement).GetAttribute("id"), Int32), _
                             ._strName = CType(myXML, XmlElement).GetAttribute("name").ToString, _
                             .AddNuc = (From NucXML In CType(myXML, XmlElement) _
                 Select New Nuclides With {._iID = CType(CType(NucXML, XmlElement).GetAttribute("rsic"), Int32), _
                                           ._strName = CType(NucXML, XmlElement).GetAttribute("nucname").ToString})}
I understand the benefits of being able to query off of objects...That is pretty beneficial....

Not really sure how great the Linq to xml or Linq to SQL is...i would rather do it myself and have more control over it.

What is everyones thoughts on Linq???

amtrac24 is offline   Reply With Quote
Old September 20th, 2008, 01:20 AM     #3 (permalink)
Ultimate Member
 
Join Date: Oct 2001
Posts: 20,454
i'm no expert in it, but friend of mine that is into C# is really liking it
I have no clue on XML stuff, so I can't comment on how it is for that type of information.

I've been stuck in vbs land for awhile, so having something that has more control over text manipulation is always a good thing, and linq provides that w/o full iteration over the text

vass0922 is online now   Reply With Quote
Old September 20th, 2008, 01:29 AM     #4 (permalink)
Member
 
Join Date: Oct 2003
Posts: 247
some features

some features are really cool. Added a a new object with line 3 lines of code is awesome. The ability to query classes without having to write all the iterations yourself is helpful.

Ahhh vbs...I use to do alot of work in vbs...my last job was with actuaries. They love their excel spreadsheets!
amtrac24 is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
C# + LINQ Help vass0922 Webmastering and Programming 5 July 24th, 2008 03:08 PM
Need help converting XML file to another XML file.. sulusulu General Tech Discussion 0 April 20th, 2007 06:19 PM
XML Help, Please! -5H4K- General Tech Discussion 1 January 12th, 2006 01:52 PM
XML Help UpYourz Webmastering and Programming 8 October 19th, 2004 11:08 PM
what's xml, sql, and whatever else there is? <[o_0]> Webmastering and Programming 18 January 27th, 2002 06:54 PM

Most Active Discussions
Is It Just Me? (522)
Misery Loves Company... (1849)
Why Does the MOON Grow Bigger as It.. (16)
heatsink issue (10)
New Mobo (18)
SSD's, RAID, and External Backup (7)
1 internet. 1 house. 3 computer. ho.. (13)
Is This A Compatible Gaming PC? (18)
UPGRADING C/D DRIVE TO 250GB & .. (12)
Recent Discussions
PNY vs Gainward (3)
UPGRADING C/D DRIVE TO 250GB &a.. (12)
Linksys WRT54G (2)
Contest: Logo and Banner design.. (0)
Hotmail Q (2)
SSD's, RAID, and External Backu.. (7)
Laptop doesn't stay connected t.. (7)
Computer won't start (4)
Official World of Warcraft Thre.. (4528)
FS: Dell 6000 laptop, modded 36.. (2)
Apple iPod touch 16 GB $200 (4)
Six 28-Disc Cross Design Black .. (4)


All times are GMT -4. The time now is 11:00 AM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28