本文整理汇总了Golang中github.com/beevik/etree.Document.FindElement方法的典型用法代码示例。如果您正苦于以下问题:Golang Document.FindElement方法的具体用法?Golang Document.FindElement怎么用?Golang Document.FindElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/beevik/etree.Document
的用法示例。
在下文中一共展示了Document.FindElement方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: getReferencedXML
func getReferencedXML(reference *etree.Element, inputDoc *etree.Document) (outputDoc *etree.Document, err error) {
uri := reference.SelectAttrValue("URI", "")
uri = strings.Replace(uri, "#", "", 1)
// populate doc with the referenced xml from the Reference URI
if uri == "" {
outputDoc = inputDoc
} else {
path := fmt.Sprintf(".//[@ID='%s']", uri)
e := inputDoc.FindElement(path)
if e != nil {
outputDoc = etree.NewDocument()
outputDoc.SetRoot(e.Copy())
} else {
// SAML v1.1 Assertions use AssertionID
path := fmt.Sprintf(".//[@AssertionID='%s']", uri)
e := inputDoc.FindElement(path)
if e != nil {
outputDoc = etree.NewDocument()
outputDoc.SetRoot(e.Copy())
}
}
}
if outputDoc == nil {
return nil, errors.New("signedxml: unable to find refereced xml")
}
return outputDoc, nil
}
示例2: updateJobConfigXml
func updateJobConfigXml(doc *etree.Document, cfg map[string]string) {
eDesc := doc.FindElement(Root + Description)
eDesc.SetText(cfg["desc"])
eRepoURL := doc.FindElement(Root + Scm + UsrRemoteConfigs + HudsonPluginsGitUserRemoteConfig + Url)
eRepoURL.SetText(cfg["repositryurl"])
eCredentialsid := doc.FindElement(Root + Scm + UsrRemoteConfigs + HudsonPluginsGitUserRemoteConfig + CredentialsId)
eCredentialsid.SetText(cfg["credentialsid"])
eBranchesToBuild := doc.FindElement(Root + Scm + Branches + HudsonPluginsGitBranchSpec + Name)
eBranchesToBuild.SetText(cfg["branchestobuild"])
eRepoName := doc.FindElement(Root + Builders + ComCloudbeesDockerpublishDockerBuilder + RepoName)
eRepoName.SetText(cfg["repositryname"])
eTag := doc.FindElement(Root + Builders + ComCloudbeesDockerpublishDockerBuilder + RepoTag)
eTag.SetText(cfg["tag"])
eDockerHostUri := doc.FindElement(Root + Builders + ComCloudbeesDockerpublishDockerBuilder + Server + Uri)
eDockerHostUri.SetText(cfg["dockerhosturi"])
eDockerRegistryUrl := doc.FindElement(Root + Builders + ComCloudbeesDockerpublishDockerBuilder + Registry + Url)
eDockerRegistryUrl.SetText(cfg["dockerregistryurl"])
eSkipPush := doc.FindElement(Root + Builders + ComCloudbeesDockerpublishDockerBuilder + SkipPush)
eSkipPush.SetText(cfg["skippush"])
eCmd := doc.FindElement(Root + Builders + HudsonTasksShell + Command)
eCmd.SetText(cfg["command"])
}