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

  • SEARCH
  • Home
  • 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 8302573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:19:30+00:00 2026-06-08T17:19:30+00:00

I was wondering how to get to a specific node using R’s XML package.

  • 0

I was wondering how to get to a specific node using R’s XML package. Here is an example using R’s built in data set, mtcars.

fileName <- system.file("exampleData", "mtcars.xml", package="XML") 
doc <- xmlTreeParse(fileName)
doc$doc$children$dataset

Running the above code gives me the ff. results:

....
 <record id="Fiat 128">32.4   4  78.7  66 4.08 2.200 19.47  1  1    4    1</record>
 <record id="Honda Civic">30.4   4  75.7  52 4.93 1.615 18.52  1  1    4    2</record>
 <record id="Toyota Corolla">33.9   4  71.1  65 4.22 1.835 19.90  1  1    4    1</record>
 <record id="Toyota Corona">21.5   4 120.1  97 3.70 2.465 20.01  1  0    3    1</record>
 <record id="Dodge Challenger">15.5   8 318.0 150 2.76 3.520 16.87  0  0    3    2</record>
 <record id="AMC Javelin">15.2   8 304.0 150 3.15 3.435 17.30  0  0    3    2</record>
 <record id="Camaro Z28">13.3   8 350.0 245 3.73 3.840 15.41  0  0    3    4</record>
 <record id="Pontiac Firebird">19.2   8 400.0 175 3.08 3.845 17.05  0  0    3    
....

I’m wondering how do I select specific nodes and get their values using xmlAttrs. For example, how would I select the node: <record id="Fiat 128"> or the node <record id="Honda Civic">

  • 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-06-08T17:19:32+00:00Added an answer on June 8, 2026 at 5:19 pm
    doc <- xmlTreeParse(fileName)
    doc <- xmlParse(fileName) 
    xpathSApply(doc,"//*/record[@id=\"Fiat 128\"]",xmlValue)
    xpathSApply(doc,"//*/record[@id=\"Honda Civic\"]",xmlValue)
    

    use xmlParse which is equivalent to xmlTreeParse(useInternalNodes=T) for
    info on xpath see https://www.w3schools.com/xml/xpath_syntax.asp

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Googling has been difficult because I can't get results specific enough - wondering if
I was wondering if using require() in node.js was the equivalent to lazy loading?
I wondering how can I select columns with specific collation. For example, I want
I am wondering how do you go about updating an XML string using XML
I am wondering how to get the bitmap from specific location as follows: try
I'm wondering how can I get the Google ranking for a specific page from
I was wondering if its possible to get the absolute position of specific HTML
I was wondering what are the specific javascript libraries required to get the method
Programming noob here. Just wondering what the best way to extract specific bits of
Creating some regex expressions here. I was wondering if I could get some pointers

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.