In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
How to use go to parse svn log generated xml format files, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can get something.
Want to use go to do a statistical svn code submission tool, similar to statsvn.
Today, we use go to parse the xml format file generated by svn log, and find an Example on go doc, which already includes some typical parsing cases, but we still encounter problems when we follow the picture. There are multiple path under a paths, and each path has its own attributes and values. It takes a lot of effort to simultaneously channel attributes and values.
Let's start with the demo of log in svn xml format.
Example
Fukun2015-03-13T11:05:17.341130Z/BigDataPlatform/trunk/application/controllers/Enterpriseajaxapi.php/BigDataPlatform/trunk/application/models/ChartDataFormater.php/BigDataPlatform/trunk/application/controllers/Mediaajaxapi.php abstracts the method of formatting line chart zhengjin2015-03-13T11:04:50.450051Z/BigDataPlatform/trunk/public/static/js/mapChart.js map event response
Parsing everything else went well, but I had some trouble parsing the paths block. If... Paths [] Path `xml: "paths" `...
Example
Type Path struct {Kind string `xml: "kind,attr" `Action string `xml: "action,attr" `Path string `xml: "Path" `}
In this way, only one path can be obtained, but if you use Paths [] Path `xml: "paths > path" `, you can only get the values of Action and Kind, but not the value of path. After looking at a few more examples on stackoverflow, I found that there was a usage of chardata. Only then did I know that the specified value could still be used in this way. Change the xml definition of Path's struct Path to `xml: ", chardata" `, and you can get the value smoothly.
Reference:
Data structures related to representing XML
① type Name struct {
Space, Local string
}
Local represents the local name, and Space represents the namespace prefix (namespace identifier). This type does not provide any method. The main purpose is to define a type on the root element of XML. The variable name must be XMLName, and the type must be: xml.Name.
② Attr (attribute), CharData (character data), Comment (comment), ProcInst (processing instruction), etc. These types are all representations defined by the XML standard. If you are interested, you can check out the standard comparison learning of XML.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.