-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
encoding/xml: no way to extract value of tag when namespaced tag with same name occurs later #3703
Labels
Milestone
Comments
Having this same issue trying to parse RSS from Slashdot. They include <link> as per the standard, then later include <atom10:link>, and no global xmlns on the main <rss> tag to help disambiguate the two, so the first literally has no namespace at all. I tried several things to get around this, including using `xml:" link"` to explicitly specify to match a blank namespace (which was a long shot, obviously), and then found that the code I'm looking for is src/pkg/encoding/xml/read.go on line 242 which (rightfully) ignores an empty namespace so that if we don't care about namespaces, we don't have to specify them. I'm not exactly sure what a solid fix for this might be, but figured I would add an extra couple cents here. My only idea is to add a special case namespace string that intentionally matches the case of an empty namespace (thus a tag like `xml:"_ link"`), but that might conflict with using something like xmlns:_="http://example.com" or xmlns:something="_" (which I freely admit that I don't know if are valid, thus whether really are problems). |
Did a little digging and found out that technically speaking, xmlns:_="http://example.com" is valid. (see http://www.w3.org/TR/REC-xml/#NT-NameStartChar) Not sure what simple alternative could be provided, but figured I'd add a little followup to my earlier idea. I also am not sure whether or not that specific example has enough real world use to have an appreciable negative impact. This cursory Google search (https://google.com/search?q="xmlns%3A_") suggests that at least one person is using it, but there really aren't all that many hits, for what it's worth. |
This issue was closed by revision 4dd3e1e. Status changed to Fixed. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: