hrbrmstr / xmlview

:page_with_curl: Format, Query and Pretty Print 'HTML'/'XML' Content in R (RStudio viewer or browser)
Other
46 stars 4 forks source link

link to listviewer issue requesting this functionality #1

Open timelyportfolio opened 8 years ago

timelyportfolio commented 8 years ago

So glad you decided to do this. I thought I should link this issue in listviewer https://github.com/timelyportfolio/listviewer/issues/2 which requests related functionality.

hrbrmstr commented 8 years ago

i cld (prbly easily) put an xpath input box at the top and have it dynamically filter the results. so much for it being a tiny pkg :-)

On Tue, Jan 12, 2016 at 2:50 PM, timelyportfolio notifications@github.com wrote:

So glad you decided to do this. I thought I should link this issue in listviewer timelyportfolio/listviewer#2 https://github.com/timelyportfolio/listviewer/issues/2 which requests related functionality.

— Reply to this email directly or view it on GitHub https://github.com/hrbrmstr/xmlview/issues/1.

timelyportfolio commented 8 years ago

Maybe as an option, but I certainly don't think you want an input box by default on all xml_view. Also, Shiny gives us a good option here.

#devtools::install_github("hrbrmst/xmlview")

library(xmlview)
library(shiny)
library(xml2)

xmld <- xml(paste0(
  "<note><to>Tove</to><from>Jani</from><heading>Reminder</heading>",
  "<body>Don't forget me this weekend!</body></note>"
))

ui <- fluidPage(
  fluidRow(
    column(6, textInput('xpath1','xpath')),
    column(6, xmlviewOutput('xmlview1'))
  )
)

server <- function(input, output, session){
  output$xmlview1 <- renderXmlview({
    if(input$xpath1 == ""){
      xml_view(xmld)
    } else {
      xml_view(xml_find_all(xmld,input$xpath1))
    }
  })
}

shinyApp(ui,server)
hrbrmstr commented 8 years ago

actually, take a look at v0.2.0 (just pushed). basic XPath filtering (there's a new option to xml_view to use a filter bar). no need for shiny for this. I just need to tweak the interface a bit and also do some error messaging for invalid XPath. This cld be a pretty helpful tool for making decent XPath :-)

hrbrmstr commented 8 years ago

I'll have to deal with namespaces soon, but it's on a gd trajectory.

timelyportfolio commented 8 years ago

Very nice, just tried it out. Works great in RStudio Viewer and Chrome but not Firefox. I left some line notes about the use of id. Let me know if you would like a pull request to illustrate use of class instead. Great work!

hrbrmstr commented 8 years ago

It gets "ugh" with large XML docs but I modified it so the parsing happens only once. The XML that gets stuck into <pre><code> isn't actually XML, so there's pretty much no chance of it getting confused (just tried it but will rig up some tests to validate my assumption). I also parse the passed-in XML outside document and only look for the XPath inside that external object, so there shldn't be confusion. Again, a test suite shld help validate.

On Tue, Jan 12, 2016 at 9:55 PM, timelyportfolio notifications@github.com wrote:

Very nice, just tried it out. Works great in RStudio Viewer and Chrome. I left some line notes about the use of id. Let me know if you would like a pull request to illustrate use of class instead.

— Reply to this email directly or view it on GitHub https://github.com/hrbrmstr/xmlview/issues/1#issuecomment-171141484.

hrbrmstr commented 8 years ago

I've relied on Bootstrap/Foundation & jQuery for so long that keeping with vanilla JS and basic CSS is proving to be a fun exercise, too :-)

On Tue, Jan 12, 2016 at 9:58 PM, boB Rudis bob@rudis.net wrote:

It gets "ugh" with large XML docs but I modified it so the parsing happens only once. The XML that gets stuck into <pre><code> isn't actually XML, so there's pretty much no chance of it getting confused (just tried it but will rig up some tests to validate my assumption). I also parse the passed-in XML outside document and only look for the XPath inside that external object, so there shldn't be confusion. Again, a test suite shld help validate.

On Tue, Jan 12, 2016 at 9:55 PM, timelyportfolio <notifications@github.com

wrote:

Very nice, just tried it out. Works great in RStudio Viewer and Chrome. I left some line notes about the use of id. Let me know if you would like a pull request to illustrate use of class instead.

— Reply to this email directly or view it on GitHub https://github.com/hrbrmstr/xmlview/issues/1#issuecomment-171141484.

timelyportfolio commented 8 years ago

I can imagine big XML docs cause some trouble in creation and filtering.