本文整理匯總了Golang中ru/kovalkov/xmltextreader.XmlTextReaderPtr.Value方法的典型用法代碼示例。如果您正苦於以下問題:Golang XmlTextReaderPtr.Value方法的具體用法?Golang XmlTextReaderPtr.Value怎麽用?Golang XmlTextReaderPtr.Value使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ru/kovalkov/xmltextreader.XmlTextReaderPtr
的用法示例。
在下文中一共展示了XmlTextReaderPtr.Value方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getText
func getText(reader *xmltextreader.XmlTextReaderPtr) string {
res := reader.Read()
eventType := reader.NodeType()
for xmltextreader.XML_END_ELEMENT != eventType && xmltextreader.XML_TEXT_NODE != eventType && res != -1 {
res = reader.Read()
eventType = reader.NodeType()
}
if xmltextreader.XML_TEXT_NODE == eventType {
return reader.Value()
}
return ""
}
示例2: getParaToTagEnd
func getParaToTagEnd(reader *xmltextreader.XmlTextReaderPtr, tag string, fb2Pointer string, weightMult float32, c chan *Word) {
res := reader.Read()
eventType := reader.NodeType()
var (
strong byte = 1 << 0
emphasis byte = 1 << 1
link byte = 1 << 2
)
var name string
var styles byte = 0
for !(eventType == xmltextreader.XML_END_ELEMENT && tag == reader.Name()) && res != -1 {
if xmltextreader.XML_TEXT_NODE == eventType {
var weight float32 = 1.0
if styles&strong != 0 {
weight += 0.2
} else if styles&emphasis != 0 {
weight += 0.1
} else if styles&link != 0 {
weight += 0.1
}
if len(fb2Pointer) > 0 {
sendWords(reader.Value(), fb2Pointer, weight*weightMult, c)
}
} else if xmltextreader.XML_START_ELEMENT == eventType {
name = reader.Name()
if emphasis_tag == name {
styles |= emphasis
} else if strong_tag == name {
styles |= strong
} else if link_tag == name {
styles |= link
}
} else if xmltextreader.XML_END_ELEMENT == eventType {
name = reader.Name()
if emphasis_tag == name {
styles &^= emphasis
} else if strong_tag == name {
styles &^= strong
} else if link_tag == name {
styles &^= link
}
}
res = reader.Read()
eventType = reader.NodeType()
}
}