|
|
.NET and XML

|
List Price: $39.95
Our Price: $3.10
Your Save: $36.85 ( 92% )
Availability: Please click buy button for full availability
information. Average Customer Rating:
    
Manufacturer: O'Reilly Media, Inc.
|
|
|
Binding: Paperback Dewey Decimal Number: 005.276 EAN: 9780596003975 Format: Illustrated ISBN: 0596003978 Label: O'Reilly Media, Inc. Manufacturer: O'Reilly Media, Inc. Number Of Items: 1 Number Of Pages: 400 Publication Date: 2003-07 Publisher: O'Reilly Media, Inc. Studio: O'Reilly Media, Inc.
|
|
|
|
|
|
Spotlight customer reviews:
|
Customer Rating:      Summary: Hardly a Java book! Comment: A careful reader would have noticed the "using" keyword in the code sample, and realized that this is C#, not Java. I found this book a good supplement to the MSDN; its well-conceived examples got me off to a good start in this area.
Customer Rating:      Summary: aaaarrrrggggg Who wants java examples in a .net book Comment: i was looking for example on using the System.xml.serialize name space. This is the example copied from the book
public enum AddressType {
Home,
Office,
Billing,
Shipping,
Mailing,
Day,
Evening,
FAX
}
If you'll look again at Example 9-7, you'll see that each state is actually listed by its full name, not the abbreviation as listed in the State enumeration. Here I've added an XmlEnumAttribute for each state name. Note that I've skipped some in the interest of space:
public enum State {
[XmlEnum(Name="Alaska")]
AK,
[XmlEnum(Name="Alabama")]
AL,
[XmlEnum(Name="Arkansas")]
AR,
[XmlEnum(Name="Arizona")]
AZ,
// ...
[XmlEnum(Name="Washington")]
WA,
[XmlEnum(Name="Wisconsin")]
WI,
[XmlEnum(Name="West Virginia")]
WV,
[XmlEnum(Name="Wyoming")]
WY
}
The Address class has one attribute, type, and four elements. Here I've added XmlAttributeAttribute and XmlElementAttribute, as appropriate. The AttributeName and ElementName fields of each attribute are used to set the names of the XML attributes and elements, respectively:
public class Address {
[XmlAttribute(AttributeName="type")]
public AddressType AddressType;
[XmlElement(ElementName="street")]
public string[ ] Street;
[XmlElement(ElementName="city")]
public string City;
[XmlElement(ElementName="state")]
public State State;
[XmlElement(ElementName="zip")]
public string Zip;
}
Similar to Address, the TelephoneNumber class has one attribute and three elements. Again, I've decorated each member with the appropriate attribute. Note also that here, as in Address, I've set the names of the attributes and elements to match the ones in the XML; that is, they all start with lowercase letters:
public class TelephoneNumber {
[XmlAttribute(AttributeName="type")]
public AddressType AddressType;
[XmlElement(ElementName="areacode")]
public string AreaCode;
[XmlElement(ElementName="exchange")]
public string Exchange;
[XmlElement(ElementName="number")]
public string Number;
}
Now we come to the meat of the personnel record, the Employee. This class has three attributes: firstname, middleinitial, and lastname, which I've treated with the appropriate attribute. However, the Employee class also has two additional elements, addresses and telephones. These two elements actually contain nested arrays of elements, so I've used the XmlArray and XmlArrayItem attributes to help the serializer figure out what to do with the XML elements it reads:
public class Employee {
[XmlAttribute(AttributeName="firstname")]
public string FirstName;
[XmlAttribute(AttributeName="middleinitial")]
public string MiddleInitial;
[XmlAttribute(AttributeName="lastname")]
public string LastName;
[XmlArray(ElementName="addresses")]
[XmlArrayItem(ElementName="address")]
public Address [ ] Addresses;
[XmlArray(ElementName="telephones")]
[XmlArrayItem(ElementName="telephone")]
public TelephoneNumber [ ] TelephoneNumbers;
[XmlAttribute(AttributeName="hiredate")]
public DateTime HireDate;
}
Here's the document element, personnel, which is decorated with XmlRootAttribute. Although the Employees member is an array of Employee objects, it is not a nested array, like addresses and telephones. By adding the XmlElement attribute directly to the member, the XmlSerializer knows that this member is to be serialized as an array of employee elements, without a separate top-level element:
[XmlRoot(ElementName="personnel")]
public class Personnel {
[XmlElement(ElementName="employee")]
public Employee [ ] Employees;
}
Finally, I've made some changes to the Serializer class, which I introduced in Example 9-5. Serializer's Main( ) method still uses the CreatePersonnel( ) to create some personnel records, but it then instantiates an XmlSerializer to deserialize the objects it created back out to a file:
public class Serializer {
public static void Main(string [ ] args) {
Personnel personnel = CreatePersonnel( );
XmlSerializer serializer = new XmlSerializer(typeof(Personnel));
using (FileStream stream = File.OpenWrite("Personnel.xml")) {
serializer.Serialize(stream,personnel);
}
}
}
notice its in java??? for crying out loud if your going to say .net and xml use .net examples not JAVA
Customer Rating:      Summary: Very Disappointed Comment: Note that I decided to write this review because I could not believe that so many people wrote so nice reviews about this book. My assumption is that someone or some people are really trying to sell this book, because this book is definitely not that good whatsoever.
Actually, this book is definitely not what I expected from a .NET/XML book. I was expecting a practical book with some theory, a good description about .NET's XML implementation and good examples. This is not what this book included. I'm very flexible with books. It's impossible that every book will be perfect. Actually, most aren't, so you have to get used to it, but again this book is for the most part terrible, unless you only want to get a general idea of how to use XML with .NET, otherwise get a different book. Again, I don't know where the reviews for this book came from, because this book is really not that good.
To name a couple of things that I find wrong with the book, lets start with the examples included. Two words: they suck! Each chapter is pretty much like this: here is the general theory, some of it unnecessary like the constant reference to W3C stuff; then, here are a few lame, simple examples without much substance; now, lets go to the next chapter.
The first time I looked inside the book I was looking for information about how .NET did Xml Validation, and it is just terrible. I actually found more information out of general .NET books I already had, than from this one. And when you are working on a project where you need this information, and you have a book that's suppose to help you with this stuff, it is very disappointing to find out that the book is pretty much irrelevant.
You would assume validation is a very important XML topic, among many others, but there's really not a lot of info on it. Actually, if you look on the book's index, you'll see that about half the related info is in the reference section, which you could get out of MSDN anyway. BTW, almost half of the book is simply reference for the different .NET XML namespaces. Again, the same data you could get out of MSDN.
In any case, I know there's not much else to choose from, but pretty much anything else might be as good or possibly way better...
Customer Rating:      Summary: Just what I was looking for! Comment: Over the years, I've found it increasingly difficult to buy technology related books simply because of the speed in which they become obsolete. So now I look at each book as not only an instructional tome, but whether or not it will be useful 6 months down the road as a reference. This book (like many of O'Reilly's titles) has easily earned a place in my library.
Mr. Bornstein's method of writing seems to fit very well with the way I learn, and his coverage of the subject matter makes this book a great resource when I'm trying to remember the exact syntax of a specific method call.
Customer Rating:      Summary: Solid introduction with a light reference section Comment: This book has probably all you need to know about reading, writing, formatting and sending XML over the wire with C#. Standout chapters for me were chapters seven, on XSLT, and nine, on web services. That being said all of the non-reference chapters were evenly written, easy reads and neither rat hole nor pander to the reader. The code samples are numerous but they are hilighted with bold to emphasizes the portions that a critical to the narrative.C# is the only imperative language covered in the book even though most .NET authors cover both C# and VB.NET. In the introduction the author calls C# the central language of .NET and says it's the best language for the job. I don't have big issues about that but other potential .NET readers may, especially considering the popularity of VB.NET. Personally I prefer when the author chooses one language and then leaves the other to the site or the CD. I think VB.NET example code fragments on the O'Reilly site probably would have been a safer bet. It's this one language approach in the dual language .NET environment that kicks the rating from five down to four.
|
|
|
Editorial Reviews:
|
|
If you're seeking ways to build network-based applications or XML-based web services, Microsoft provides most of the tools you'll need. XML is integrated into the .NET Framework and Visual Studio .NET, but if you want to get a grasp on how .NET and XML actually work together, that's a different story. With,"NET & XML," you can get under the hood to see how the .NET Framework implements XML, giving you the skills to write understandable XML-based code that interoperates with code written with other tools, and even other languages. ,"NET & XML" starts by introducing XML and the .NET Framework, and then teaches you how to read and write XML before moving on to complex methods for manipulating, navigating, transforming, and constraining it. To demonstrate the power of XML in .NET, author Niel Bornstein builds a simple hardware store inventory system throughout the book. As you move from chapter to chapter, you'll absorb increasingly complex information until you have enough knowledge to successfully program your own XML-based applications. This tutorial also contains a quick reference to the API, plus appendices present additional .NET assemblies that you can use to work with XML, and how to work with the .NET XML configuration file format. One study puts the potential market for new software based on XML at or near $100 billion over the next five years. The .NET Framework gives you a way to become a part of it. But to use XML and .NET effectively, you need to understand how these two technologies work together. This book gives you the insight to take full advantage of the power the two provide.
|
|
|
|
|
|
|