Register and join over 40,000 other developers!
Recent Topics
-
Print specific values from dictionary with a specific key name
Siten0308 - Jun 20 2019 01:43 PM
-
Learn algorithms and programming concepts
johnnylo - Apr 23 2019 07:49 AM
-
Job Gig PHP Form Needed
PJohnson - Apr 18 2019 03:55 AM
-
How to make code run differently depending on the platform it is running on?
xarzu - Apr 05 2019 09:17 AM
-
How do I set a breakpoint in an attached process in visual studio
xarzu - Apr 04 2019 11:47 AM
Recent Blog Entries
Recent Status Updates
Popular Tags
- networking
- Managed C++
- stream
- console
- database
- authentication
- Visual Basic 4 / 5 / 6
- session
- Connection
- asp.net
- import
- syntax
- hardware
- html5
- array
- mysql
- java
- php
- c++
- string
- C#
- html
- loop
- timer
- jquery
- ajax
- javascript
- programming
- android
- css
- assembly
- c
- form
- vb.net
- xml
- linked list
- login
- encryption
- pseudocode
- calculator
- sql
- python
- setup
- help
- game
- combobox
- binary
- hello world
- grid
- innerHTML

9 replies to this topic
#1
Posted 12 October 2012 - 02:31 PM
I have XML file that I have write with XMLWritter class within my project. How to read that XML file in console?
I have try many codes but they are not working.
I have try many codes but they are not working.
Microsoft Student Partner, Microsoft Certified Professional
#2
Posted 12 October 2012 - 02:33 PM
Can you just use DataSet and use method like LoadXML or ReadXML ... then it returns a Dataset ... then you can parse it from there through rows and columns. It has been a while for me to play with xml.
www.pickmike.com
I don't just develop software. I find solutions to your business needs.
#3
Posted 12 October 2012 - 02:36 PM
I was last playing with XML before one year. I forget 90% of everything.
Can you give me an example?
Can you give me an example?
Microsoft Student Partner, Microsoft Certified Professional
#4
Posted 12 October 2012 - 02:42 PM
www.pickmike.com
I don't just develop software. I find solutions to your business needs.
#5
Posted 12 October 2012 - 02:51 PM
Not helpfull. Let me specify my need.
First, I need to read the name of the XML document,
second, I need to read root element,
third, I need to read attribute elements and their values.
Those 3 things need to be written in console separated.
First, I need to read the name of the XML document,
second, I need to read root element,
third, I need to read attribute elements and their values.
Those 3 things need to be written in console separated.
Microsoft Student Partner, Microsoft Certified Professional
#6
Posted 12 October 2012 - 03:26 PM
Dataset should contains everything you need. All you have to do is to debug or loop through and print out the column name, and look in the debug table. Your root should be the Datatable.
www.pickmike.com
I don't just develop software. I find solutions to your business needs.
#7
Posted 12 October 2012 - 04:06 PM
XmlDocument doc = new XmlDocument(); doc.Load("employees.xml"); XmlNodeList customers = null; customers = doc.SelectNodes("Employees"); foreach (XmlNode customer in customers) { Console.WriteLine("ID = {0}, Ime = {1}, Prezime = {2}", customer.Attributes["ID"].Value, customer.Attributes["FirstName"].Value, customer.Attributes["LastName"].Value); } Console.ReadKey();
This is the code I found. It is easier to work than with DataSet and DataTable.
The only problem is this:

Microsoft Student Partner, Microsoft Certified Professional
#8
Posted 12 October 2012 - 04:38 PM
Then I guess all you have to do is write a wrapper ... eg: printValue(object value)
if (value != null) { // print it out ... }
then wrap around all the column names that you want to print it out.
if (value != null) { // print it out ... }
then wrap around all the column names that you want to print it out.
www.pickmike.com
I don't just develop software. I find solutions to your business needs.
#9
Posted 12 October 2012 - 05:06 PM
try { XmlDocument doc = new XmlDocument(); doc.Load("employees.xml"); XmlNodeList customers = null; customers = doc.SelectNodes("Employees"); if (customers != null) { foreach (XmlNode customer in customers) { if (customers != null) { Console.WriteLine("ID = {0}, Ime = {1}, Prezime = {2}", customer.Attributes["ID"].Value, customer.Attributes["FirstName"].Value, customer.Attributes["LastName"].Value); } } } } catch (Exception e) { Console.WriteLine(e.ToString()); } Console.ReadKey();

Line 28 is where I print out values of nodes. And if I make like this:
if (customer != null) { ... }
then I get the same exception but this time for line 26 which is if statement.
And if I print out only customer.Name then application is executing normaly and I get the name of the node.
Microsoft Student Partner, Microsoft Certified Professional
#10
Posted 12 October 2012 - 05:56 PM
I meant this:
printValue(customer.Attributes["ID"].Value)
and do the rest for all of them.
printValue(customer.Attributes["ID"].Value)
and do the rest for all of them.
www.pickmike.com
I don't just develop software. I find solutions to your business needs.
Also tagged with one or more of these keywords: xml, xmlreader
Language Forums →
Java →
[JAXB API] XmlElementWrapper - No items in the ArrayStarted by Crusher, 11 Nov 2015 ![]() |
|
![]() |
||
Language Forums →
PHP →
How to solve - Node no longer existStarted by anjshr7, 21 Jul 2015 ![]() |
|
![]() |
||
Language Forums →
PHP →
Fatal error: Call to undefined method SimpleXMLElement::attribute()Started by anjshr7, 20 Jul 2015 ![]() |
|
![]() |
||
Language Forums →
PHP →
parent html content included in xml outputStarted by yonghan79, 30 May 2015 ![]() |
|
![]() |
||
Language Forums →
PHP →
To get the data in the xml in the url ( shown below) and then print the rates it to the screen and copy it to the mongodb colle...Started by ShebeerAhammed, 14 Apr 2015 ![]() |
|
![]() |
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download