1
0
mirror of https://github.com/fumiama/go-docx.git synced 2026-06-06 00:00:24 +08:00
Files
go-docx/structlink.go
2023-02-20 22:48:04 +08:00

38 lines
561 B
Go

package docxlib
import (
"encoding/xml"
"io"
)
// Hyperlink element contains links
type Hyperlink struct {
XMLName xml.Name `xml:"w:hyperlink,omitempty"`
ID string `xml:"r:id,attr"`
Run Run
}
func (r *Hyperlink) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
for {
t, err := d.Token()
if err == io.EOF {
break
}
if err != nil {
return err
}
switch tt := t.(type) {
case xml.StartElement:
if tt.Name.Local == "r" {
d.DecodeElement(&r.Run, &start)
} else {
continue
}
}
}
return nil
}