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 9207641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:25:57+00:00 2026-06-18T00:25:57+00:00

how to parse a text file. i have a xml response stored in a

  • 0

how to parse a text file.

i have a xml response stored in a text file i have,

<item>
<title geoid="2405">Maryland</title>
<description cong_dist="Congressional District 5">MD - Congressional District 5 <br/> No of Incidents: 4627</description>
<latitude>38.584128</latitude>
<longitude>-76.796848217734</longitude>
<georss:where>
<georss:polygon>38.702820547525 -76.531788346774 38.699669 -76.532537 38.691483067884 -76.532483595111 38.678363 -76.532398 38.668638351202 -76.530063988263 38.654562061162 -76.526685539659 38.645956 -76.52462 38.645269636055 -76.524245033111 38.640885760613 -76.521850081935 38.629361 -76.515554 38.615745 -76.511278 38.590229 -76.51634 38.555763 -76.515106 38.539149 -76.517506 38.537207756341 -76.517162112726 38.528988 -76.515706 38.50461 -76.506023 38.482997828117 -76.492790125676 38.482849 -76.492699 38.451233 -76.455799 38.450411034397 -76.455848927893 38.447891 -76.456002 38.446556103643 -76.45476571365 38.442422 -76.450937 38.433429 -76.436271 38.414682 -76.415384 38.396003 -76.40271 38.389477 -76.393378 38.387781 -76.388348 38.382013 -76.386229 38.364206709193 -76.386892465863 38.361267 -76.387002 38.341089 -76.40494 38.340713058044 -76.4050476356 38.33628 -76.408871 38.328088 -76.414539 38.319072 -76.421601 38.322185 -76.426075 38.324977 -76.436098 38.324977 -76.43848 38.322825 -76.451438 38.324633 -76.4517 38.325411 -76.449782 38.328684 -76.449114 38.329975 -76.448962 38.332278 -76.448185 38.332758 </georss:polygon>
<georss:polygon>38.268945 -76.864292 38.26986 -76.864903 38.270189 -76.864585 38.266112 -76.855873 38.264397 -76.851112 38.263759 -76.843681 38.263874 -76.84194 38.264561 -76.84104 38.261861 -76.837934 38.261282871941 -76.837988305571 38.254491 -76.842139 38.25616 -76.847074 38.268945 -76.864292</georss:polygon>
<georss:polygon>38.119264 -76.469798 38.115534 -76.469738 38.111392 -76.466404 38.10583 -76.46533 38.103035 -76.473266 38.104709 -76.476222 38.115873 -76.481036 38.128960028531 -76.492582005749 38.125491 -76.484719 38.123311 -76.483214 38.119171 -76.475795 38.120591 -76.472319 38.119264 -76.469798</georss:polygon>
</georss:where>
</item>

i have to parse this text file values in javascript.

how to do it,how to parse a text file values.
to open in javascript.(js)

  • 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-18T00:25:58+00:00Added an answer on June 18, 2026 at 12:25 am

    You can start from here http://www.php.net/manual/en/simplexml.examples-basic.php

    Simple Example with PHP:

    <?php
    $xml = '<?xml version="1.0" encoding="UTF-8" ?> 
    <rss> 
     <channel> 
        <item> 
            <title><![CDATA[Tom & Jerry]]></title> 
        </item> 
     </channel> 
    </rss>'; 
    
    $xml = simplexml_load_string($xml); 
    
    $myFile = "testFile.txt";//text file path
    $fh = fopen($myFile, 'w') or die("can't open file");
    $stringData = $xml->channel->item->title; 
    fwrite($fh, $stringData);
    fclose($fh);
    ?>
    

    EDIT: with Jquery

    if Xml file structure is

    <item>
       <subject></subject>
       <date></date>
       <thumb></thumb>
    </item>
    

    Using JQuery, $.ajax() method:

     var tmpSubject, tmpDate, tmpThumb;
            $.ajax({
            url: '/your_file.xml',
            type: 'GET', 
            dataType: 'xml',
            success: function(returnedXMLResponse){
                $('item', returnedXMLResponse).each(function(){
                     tmpSubject = $('subject', this).text();
                     tmpDate = $('date', this).text();
                     tmpThumb = $('thumb', this).text();
                    //Here you can do anything you want with those temporary variables
                })
            }  
        }); 
    

    Remember to include jquery file in header:

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML file which I'd like to parse into a non-XML (text)
I want to parse text from a xml file.Consider that I have a some
I have a text file to parse in Perl. I parse it from the
I have a text file and I would like to parse it using regular
I have a weird XML file that I'm trying to parse. <Data> <Row> <Field
I have an application that compared an xml file to a text file, and
I have xml of the format: <channel> <games> <game slot='1'> <id>Bric A Bloc</id> <title-text>BricABloc
I have an xml, and I can't parse this file with xmlslurper. Here a
i have a snippet of xml that i've pasted in a text file which
I have a xml file with content <ul> <li><info>CSS text formatting </info></li> </ul> Where

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.