]> Cypherpunks repositories - gostls13.git/commitdiff
encoding/xml: fix anonymous field Unmarshal example
authorGustavo Niemeyer <gustavo@niemeyer.net>
Fri, 24 Feb 2012 19:45:32 +0000 (14:45 -0500)
committerRuss Cox <rsc@golang.org>
Fri, 24 Feb 2012 19:45:32 +0000 (14:45 -0500)
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5697043

src/pkg/encoding/xml/example_test.go

index 082ce6803d3b908289173fc23b9791ec31a9d79f..97c8c0b0dc0224a8dc80d8b97f2876ad9d8671db 100644 (file)
@@ -52,7 +52,7 @@ func ExampleMarshalIndent() {
 
 // This example demonstrates unmarshaling an XML excerpt into a value with
 // some preset fields. Note that the Phone field isn't modified and that
-// the XML <address> element is ignored. Also, the Groups field is assigned
+// the XML <Company> element is ignored. Also, the Groups field is assigned
 // considering the element path provided in its tag.
 func ExampleUnmarshal() {
        type Email struct {
@@ -71,11 +71,11 @@ func ExampleUnmarshal() {
                Address
        }
        v := Result{Name: "none", Phone: "none"}
-       v.Address = Address{"Hanga Roa", "Easter Island"}
 
        data := `
                <Person>
                        <FullName>Grace R. Emlin</FullName>
+                       <Company>Example Inc.</Company>
                        <Email where="home">
                                <Addr>gre@example.com</Addr>
                        </Email>
@@ -86,7 +86,8 @@ func ExampleUnmarshal() {
                                <Value>Friends</Value>
                                <Value>Squash</Value>
                        </Group>
-                       <Address>123 Main Street</Address>
+                       <City>Hanga Roa</City>
+                       <State>Easter Island</State>
                </Person>
        `
        err := xml.Unmarshal([]byte(data), &v)