strict.go 997 B

123456789101112131415161718192021222324252627282930
  1. // Copyright 2016 Charles Banning. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file
  4. // strict.go actually addresses setting xml.Decoder attribute
  5. // values. This'll let you parse non-standard XML.
  6. package mxj
  7. import (
  8. "encoding/xml"
  9. )
  10. // CustomDecoder can be used to specify xml.Decoder attribute
  11. // values, e.g., Strict:false, to be used. By default CustomDecoder
  12. // is nil. If CustomeDecoder != nil, then mxj.XmlCharsetReader variable is
  13. // ignored and must be set as part of the CustomDecoder value, if needed.
  14. // Usage:
  15. // mxj.CustomDecoder = &xml.Decoder{Strict:false}
  16. var CustomDecoder *xml.Decoder
  17. // useCustomDecoder copy over public attributes from customDecoder
  18. func useCustomDecoder(d *xml.Decoder) {
  19. d.Strict = CustomDecoder.Strict
  20. d.AutoClose = CustomDecoder.AutoClose
  21. d.Entity = CustomDecoder.Entity
  22. d.CharsetReader = CustomDecoder.CharsetReader
  23. d.DefaultSpace = CustomDecoder.DefaultSpace
  24. }