| |
|
|
| |
|
|
| |
| |
|
|
BA 372 - XML Lab
In this lab we'll explore several ways of consuming and producing
XML files with .Net
facilities, both as files and as Web services. The examples are based
on material collected from a variety
of places.
As discussed in class, the combined rigidity and simplicity of XML
syntax
make it relatively easy to parse; hence, a variety of parsing methods
and models is available.
Study the following (DTDless) XML file and store it in c:\temp\family.xml:
<?xml version="1.0" encoding="UTF-8"?>
<family>
<person gender="male">
<name>
<firstname>Don</firstname>
<lastname>Hurst</lastname>
</name>
<job>retired</job>
</person>
<person gender="female">
<name>
<firstname>Mary</firstname>
<lastname>Hurst</lastname>
</name>
<job>dentist</job>
</person>
</family>
http://www.teachengineering.com/collection/duk_/lessons/duk_boxes_mary_less/duk_boxes_mary_less.xml
The problem here rests in the so-called namespace declared in the XML document (you might have to pull up the page source to see this):
<lesson xmlns="http://www.teachengineering.org"...
xmlns:te="http://www.teachengineering.org"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
we deserialize the XML string into a person
object called customer.