| // Copyright 2012 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| // This example demonstrates parsing HTML data and walking the resulting tree. |
| "code.google.com/p/go.net/html" |
| s := `<p>Links:</p><ul><li><a href="foo">Foo</a><li><a href="/bar/baz">BarBaz</a></ul>` |
| doc, err := html.Parse(strings.NewReader(s)) |
| if n.Type == html.ElementNode && n.Data == "a" { |
| for _, a := range n.Attr { |
| for c := n.FirstChild; c != nil; c = c.NextSibling { |