当前位置: 首页>>代码示例>>Golang>>正文


Golang Document.FindElement方法代码示例

本文整理汇总了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
}
开发者ID:ma314smith,项目名称:signedxml,代码行数:29,代码来源:signedxml.go

示例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"])

}
开发者ID:zhanglianx111,项目名称:lasa,代码行数:32,代码来源:jobs.go


注:本文中的github.com/beevik/etree.Document.FindElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。