Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 905393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:12:38+00:00 2026-05-15T16:12:38+00:00

I am trying to parse the XML file in R, so that I can

  • 0

I am trying to parse the XML file in R, so that I can analysis the data. I am trying to get the mean and standard deviation of the price. Also I would like to be able to get the rate of change in the time of the share price changing. I have tried entering the data by hand but am having problems with the date structure ( I have tried the following:

z <- strptime ("HH:MM:SS.ms, "%H:%m:%S.%f")

but it failed to work). I know the XML file only has a small few numbers but is it a process that could be automated and if so what packages would I need? (I am new to R). Any help would be much appreciated.

Thanks,
Anthony.

<?xml version = "1.0"?>
    <Company >
    <shareprice>
    <timeStamp> 12:00:00:01</timeStamp>
    <Price>  25.02</Price>
    </shareprice>



    <shareprice>
    <timeStamp> 12:00:00:02</timeStamp>
    <Price>  15</Price>
    </shareprice>



    <shareprice>
    <timeStamp> 12:00:00:025</timeStamp>
    <Price>  15.02</Price>
    </shareprice>



    <shareprice>
    <timeStamp> 12:00:00:031</timeStamp>
    <Price>  18.25</Price>
    </shareprice>



    <shareprice>
    <timeStamp> 12:00:00:039</timeStamp>
    <Price>  18.54</Price>
    </shareprice>



    <shareprice>
    <timeStamp> 12:00:00:050</timeStamp>
    <Price> 16.52</Price>
    </shareprice>


   <shareprice>
    <timeStamp> 12:00:01:01</timeStamp>
    <Price>  17.50</Price>
   </shareprice>
</Company>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T16:12:39+00:00Added an answer on May 15, 2026 at 4:12 pm

    In

    z <- strptime ("HH:MM:SS.ms, "%H:%m:%S.%f")
    

    you miss a closing " so it is invalid syntax.

    Next, the data is non-standard as we would use a dot for seconds.subseconds, ie 12:23:34.567 to denote a timestamp. The milliseconds can be parsed this way

    > ts <- "12:00:00.050"
    > strptime(ts, "%H:%M:%OS")
    [1] "2010-07-09 12:00:00 CDT"
    > 
    

    So you not only need to get it out of XML first, but also need to convert the string. Else, you can parse the string an fill a POSIXlt time structure ‘by hand’.

    Postscriptum: Forgot to mention that you need to enable printing of sub-second times:

    > options("digits.secs"=3)         # shows milliseconds (three digits)
    > strptime(ts, "%H:%M:%OS")
    [1] "2010-07-09 12:00:00.05 CDT"   # suppresses trailing zero
    > 
    

    Postscriptum 2: You are also in luck with respect to your file thanks to the XML package:

    > library(XML)
    > xmlToDataFrame("c:/Temp/foo.xml")     # save your data as c:/Temp/foo.xml
          timeStamp   Price
    1   12:00:00:01   25.02
    2   12:00:00:02      15
    3  12:00:00:025   15.02
    4  12:00:00:031   18.25
    5  12:00:00:039   18.54
    6  12:00:00:050   16.52
    7   12:00:01:01   17.50
    > 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to configure IIS to parse a .xml file just like it would
Hey guys. I'm trying to parse xml file in order to extract some data
I have a very large XML file that I need to parse so I
I am trying to parse an XML file using the SAX interface of libxml2
I'm trying to parse an XML file of tweets as retreived from Twitter's restful
I am trying to parse an xml file using SAX with Android and the
Trying to just simply parse an XML file; protected void Page_Load(object sender, EventArgs e)
I am trying to parse this XML file for a school project: http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topsongs/limit=10/genre=20/xml .
I'm trying to parse a massive xml file into my MySQL database. the file
I am trying to parse an xml log file in PHP. It has following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.