-
Notifications
You must be signed in to change notification settings - Fork 83
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
Namespace aliases #35
Comments
Why does that make it hard to navigate the document? The goal of |
I found it confusing that the node in the xml is named
Only by manually inspecting the xml I found that |
That's how xml namespaces work though - the prefix is completely arbitrary, it's only the url that identifies it. But maybe |
Having aliases to the same URI seems to work OK in limited testing. I think we should not return only unique prefixes. library(curl)
library(xml2)
h <- handle_setheaders(new_handle(customrequest = "PROPFIND"), Depth="1")
req <- curl_fetch_memory("http://svn.r-project.org/R/tags/", handle = h)
doc <- read_xml(rawToChar(req$content))
ns <- xml_ns(doc)
# Add the additional alias
ns[["lp1"]] <- "DAV:"
prop <- xml_find_all(doc, ".//D:propstat/D:prop", ns)
xml_find_one(prop, ".//lp1:getetag", ns)
#> {xml_nodeset (141)}
#> [1] <lp1:getetag>W/"70574//tags"</lp1:getetag>
#> [2] <lp1:getetag>W/"10156//tags/R-before-GenGC-merge"</lp1:getetag>
#> [3] <lp1:getetag>W/"371//tags/R-0-60"</lp1:getetag>
#> [4] <lp1:getetag>W/"1452//tags/R-0-62-1"</lp1:getetag>
#> [5] <lp1:getetag>W/"477//tags/R-0-61"</lp1:getetag>
#> [6] <lp1:getetag>W/"1721//tags/R-0-62-2"</lp1:getetag>
#> [7] <lp1:getetag>W/"1447//tags/R-0-62"</lp1:getetag>
#> [8] <lp1:getetag>W/"2012//tags/R-0-62-3"</lp1:getetag>
#> [9] <lp1:getetag>W/"2621//tags/R-0-62-4"</lp1:getetag>
#> [10] <lp1:getetag>W/"2838//tags/R-0-63"</lp1:getetag>
#> [11] <lp1:getetag>W/"4084//tags/R-0-64"</lp1:getetag>
#> [12] <lp1:getetag>W/"5635//tags/R-0-65"</lp1:getetag>
#> [13] <lp1:getetag>W/"8828//tags/R-1-0-1"</lp1:getetag>
#> [14] <lp1:getetag>W/"62482//tags/R-3-0-0"</lp1:getetag>
#> [15] <lp1:getetag>W/"62744//tags/R-3-0-1"</lp1:getetag>
#> [16] <lp1:getetag>W/"35751//tags/R-2-2-0"</lp1:getetag>
#> [17] <lp1:getetag>W/"36814//tags/R-2-2-1"</lp1:getetag>
#> [18] <lp1:getetag>W/"63988//tags/R-3-0-2"</lp1:getetag>
#> [19] <lp1:getetag>W/"18029//tags/R-1-4-1"</lp1:getetag>
#> [20] <lp1:getetag>W/"65127//tags/R-3-0-3"</lp1:getetag>
#> ...
# specifying the URI explicitly also works
xml_find_one(prop, ".//*[local-name()='getetag' and namespace-uri()='DAV:']")
#> {xml_nodeset (141)}
#> [1] <lp1:getetag>W/"70574//tags"</lp1:getetag>
#> [2] <lp1:getetag>W/"10156//tags/R-before-GenGC-merge"</lp1:getetag>
#> [3] <lp1:getetag>W/"371//tags/R-0-60"</lp1:getetag>
#> [4] <lp1:getetag>W/"1452//tags/R-0-62-1"</lp1:getetag>
#> [5] <lp1:getetag>W/"477//tags/R-0-61"</lp1:getetag>
#> [6] <lp1:getetag>W/"1721//tags/R-0-62-2"</lp1:getetag>
#> [7] <lp1:getetag>W/"1447//tags/R-0-62"</lp1:getetag>
#> [8] <lp1:getetag>W/"2012//tags/R-0-62-3"</lp1:getetag>
#> [9] <lp1:getetag>W/"2621//tags/R-0-62-4"</lp1:getetag>
#> [10] <lp1:getetag>W/"2838//tags/R-0-63"</lp1:getetag>
#> [11] <lp1:getetag>W/"4084//tags/R-0-64"</lp1:getetag>
#> [12] <lp1:getetag>W/"5635//tags/R-0-65"</lp1:getetag>
#> [13] <lp1:getetag>W/"8828//tags/R-1-0-1"</lp1:getetag>
#> [14] <lp1:getetag>W/"62482//tags/R-3-0-0"</lp1:getetag>
#> [15] <lp1:getetag>W/"62744//tags/R-3-0-1"</lp1:getetag>
#> [16] <lp1:getetag>W/"35751//tags/R-2-2-0"</lp1:getetag>
#> [17] <lp1:getetag>W/"36814//tags/R-2-2-1"</lp1:getetag>
#> [18] <lp1:getetag>W/"63988//tags/R-3-0-2"</lp1:getetag>
#> [19] <lp1:getetag>W/"18029//tags/R-1-4-1"</lp1:getetag>
#> [20] <lp1:getetag>W/"65127//tags/R-3-0-3"</lp1:getetag>
#> ... |
Yeah, that sounds fine to me. |
In this example borrowed form the rversions package
lp1:
andlp3:
namespace are aliases ofD:
howeverxml_ns
does not list them at all, making it difficult to query the document.The text was updated successfully, but these errors were encountered: