473,654 Members | 3,078 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Read xml file with multiple elements

I have the following xml file that I want to read in using vb.net 2003:

<dordivision name="district 1" propname="Distr ict 1">

<printer id="location11 " duplex="false"> Location 11</printer>

<printer id="location12 " duplex="true">L ocation 12</printer>

<printer id="location13 " duplex="true">L ocation 13</printer>

<printer id="location14 " duplex="false"> Location 14</printer>

</dordivision>

<dordivision name="district 2" propname="Distr ict 2">

<printer id="location21 " duplex="true">L ocation 21</printer>

<printer id="location22 " duplex="true">L ocation 22</printer>

</dordivision>

<dordivision name="district 3" propname="Distr ict 3">

<printer id="location31 " duplex="true">L ocation 31</printer>

<printer id="location32 " duplex="true">L ocation 32</printer>

<printer id="location33 " duplex="true">L ocation 33</printer>

<printer id="location34 " duplex="true">L ocation 34</printer>

</dordivision>

I have been able to get the names into a combobox from the dordivision
element. I would like to be able to have the user select the item from the
combobox that they want and then have the form change and display each
printer name in a list of radio buttons. This will vary from 1 to many
elements. Is this possible to do? For some reason I only get one printer.
Nov 12 '05 #1
1 6087
off the top of my head, Could be 2 problems :
1. not reading the XML properly or successfully
2. improper data binding
So, how are you getting the XML into a data structure? Serialization?
something else?
With serialization I can read in that data pretty simply like so:

Dim xmlS1 As New XmlSerializer(G etType(Info))

' de-serialize (read)
Dim path As String
path="printers. xml"
Dim r As StreamReader
r= File.OpenText(p ath)
Dim data as Info
data = xmlS1.Deseriali ze(r)
r.Close()
where Info is a type generated from xsd.exe. [To get this type, wrap your
XML in an <Info> element, then run these 2 commands in succession:
xsd.exe printers.xml
xsd.exe /language:vb /c printers.xsd

]

After reading in the XML, it becomes an issue of data binding.
Can you show us some code?

-Dino

"Mark" <ma**@somewhere .com> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
I have the following xml file that I want to read in using vb.net 2003:

<dordivision name="district 1" propname="Distr ict 1">

<printer id="location11 " duplex="false"> Location 11</printer>

<printer id="location12 " duplex="true">L ocation 12</printer>

<printer id="location13 " duplex="true">L ocation 13</printer>

<printer id="location14 " duplex="false"> Location 14</printer>

</dordivision>

<dordivision name="district 2" propname="Distr ict 2">

<printer id="location21 " duplex="true">L ocation 21</printer>

<printer id="location22 " duplex="true">L ocation 22</printer>

</dordivision>

<dordivision name="district 3" propname="Distr ict 3">

<printer id="location31 " duplex="true">L ocation 31</printer>

<printer id="location32 " duplex="true">L ocation 32</printer>

<printer id="location33 " duplex="true">L ocation 33</printer>

<printer id="location34 " duplex="true">L ocation 34</printer>

</dordivision>

I have been able to get the names into a combobox from the dordivision
element. I would like to be able to have the user select the item from
the combobox that they want and then have the form change and display each
printer name in a list of radio buttons. This will vary from 1 to many
elements. Is this possible to do? For some reason I only get one
printer.

Nov 12 '05 #2

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

Similar topics

6
1554
by: Paul M | last post by:
hi there, i have an xml file, but am not too sure how to read all these elements using vb.net code. any help would be greatly appreciated:)) <---------CODE---------------> <?xml version="1.0" encoding="utf-8"?> <weatherFeed>
1
2581
by: davis | last post by:
Hello, I am working in .Net C# and have an xml file similar to the one below. I have tried using a DataSet but get the error "The same table (Gid) cannot be the child table in two nested relations". The file has a number of parent nodes at the "<ShipmentHeader>" level, each of which have a number of child nodes. I will not know ahead of time which of these parent/child nodes will occur. I have also looked at the XmlTextReader, but it...
2
8303
by: Raghu Gupta | last post by:
Hi, Actually i am facing some problem using quickbooks and presently i am not so expert in using it. I am using c# code to retrive the data from quickbooks. it doesn't matter which language we are using. So i have .iif file of employee list,so through code i have to read .iif file and get the data out of it and store that data in database. As i can use QuickBook only to import .iif file and from quickbook i can
8
23899
by: a | last post by:
I have a struct to write to a file struct _structA{ long x; int y; float z; } struct _structA A; //file open write(fd,A,sizeof(_structA)); //file close
6
3246
by: digitalshehan | last post by:
Hi All, I have an xml file containing the following: <?xml version="1.0" encoding="utf-8"?> <Employee name="john" /> <Employee name="peter" /> <Employee name="mark" /> Can anyone let me know of away to read values from the xml file and add them to an arraylist...
5
4946
by: paul_zaoldyeck | last post by:
does anyone know how to validate an xml file against multiple defined schema? can you show me some examples? i'm making here an xml reader.. thank you
4
39416
by: desktop | last post by:
I have a main.cpp file that will call a single function. For the sake of curiousity I would like to place this function in a separate file called func.cpp and include it in my main.cpp with: #include "func.cpp". But it gives a multiple definitions error. Do I always have to make a .h file for a .cpp file if I want to include the functionality in another module?
6
3212
by: =?Utf-8?B?VGFtbXkgTmVqYWRpYW4=?= | last post by:
Hi, can someone please let me know how I can read xml elements using object oriented program. I created a class to use the get and set properties however I dont know how I can pass the values from xml file to the class and use the values in my form. Thanks -- Nejadian
8
2684
omerbutt
by: omerbutt | last post by:
hi there i have a form with multiple input (type/text ) fields and three inputs(type/file) fields i have to submit the form via ajax because i have multiple forms on this page ,you can say it is a contact_us.php page.Now i can get all the inputs at the other end else the input(type/file) i donot want a submit button what i want that some how io can send the file name and the path of the picture that is to be uploaded and send to a page via ajax...
0
8372
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
8285
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
8814
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8706
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8591
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...
0
7304
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6160
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
5621
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
4293
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.