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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:43:22+00:00 2026-06-11T22:43:22+00:00

i have aproblem for a few days right now :s … I’m trying to

  • 0

i have aproblem for a few days right now :s …
I’m trying to get some changing data inside a string, the string is something like this:

<docdata>
 <!-- News Identifier -->
        <doc-id id-string ="YBY15349" />

        <!-- Date of issue -->
        <date.issue norm ="2012-09-22 19:52" />
        <!-- Date of release -->
        <date.release norm ="2012-09-22 19:52" />
      </docdata>

What i need is only the date inside the “2012-09-22 19:52” , the string its stored in some type of xml, malformed by the way. So i can’t use normal xml parser, i load/read the file already to change some charset

    $fname = $file;
    $fhandle = fopen($fname,"r");
    $content = fread($fhandle,filesize($fname));
    str_replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>", $content); 
etc..

this work like a charm, but with the string i cant use it.
I try with preg_match_all but i can`t get it right.
Its there a simple way to search this value

<date.issue norm ="2012-09-22 19:52" />

and get just the date in a variable?

thanks in advance and sorry for my english.

  • 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-11T22:43:23+00:00Added an answer on June 11, 2026 at 10:43 pm

    From the PHP documentation:

    file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance.

    Consequently, your code would become:

    $content = file_get_contents($file);
    $content = str_replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>", $content);
    preg_match_all('/date\.issue norm ="([^"]+)" /', $content, $date);
    

    The default behavior is to store the parenthesized matches in the array $date[1]. Therefore, you might loop through $date[1][0], $date[1][1], and so on.

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

Sidebar

Related Questions

I have a problem that has been bothering me now for a few days.
I have a problem with NSNotificationCenter. Now it crashes, but a few days ago,
I have been having this problem for a few days now, and really cant
I have a problem with out of memory when I'm trying load a few
I have a problem that I'm working on for quite some time now. I
I am extremely new to Informix and am having some trouble trying to get
I have a problem that I have been struggling with for a few days
I've been asking a lot of questions here over the past few days trying
I have a simple rails application with a few controller and some rake tasks.
I have started to use jqGrid in our project a few days ago and

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.