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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:09:36+00:00 2026-06-03T16:09:36+00:00

I have the the following HTML string. <div id=mydiv> <pre> Some content several lines.

  • 0

I have the the following HTML string.

<div id="mydiv">
<pre>
Some content several lines. 

   Field1: value 2
   Field2: value 2
   Field3: value 3

Some content. several lines.
</pre>
</div>

I’m trying to get the text within the <pre> tags and break it down to its fields, so I’m using DomDocument() loadHTML() DOMXPath and query('//pre') to get the text content of <pre>.

When I var_dump its nodeValue I get formatted text just as it if were displayed using <pre>. I’m not sure why that’s the case, but I’m wondering if this can somehow help me break up the text to fields/values.

  • 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-03T16:09:38+00:00Added an answer on June 3, 2026 at 4:09 pm

    If you just want to read it in then just do it like this.

    <?php
    $preStr = ""; //Holds the pre-string.
    $preArr = explode("\n", $preStr);
    $pairs = array();
    
    foreach ($preArr AS $line) {
      $line = trim($line);
    
      if (stristr($line, ':')) {
        list($key, $value) = explode(':', $line);
        $pairs[$key] = $value;
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following HTML: <div id=mydiv> </div> I would like to load content
i have html code that looks like the following: String html = <html><head><style type=\text/css\></style></head><body><div
I have following html in string and i have to extract the content only
Say I have the following html: <div id=myDiv title=My Div>This is me!</div> I want
I have the following: string html_string = http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=pharma; string html; html = new WebClient().DownloadString(html_string);
I have the following line of code. <%= Html.Encode(string.Join(, , item.company1.companies.Select(x => x.company_name).ToArray())) %>
Let's say I have the following HTML code <div id="outer"> <div id="inner">Hello World</div> </div>
I have following string: <div> text0 </div> prefix <div> text1 <strong>text2</strong> text3 </div> text4
I have the following code- View- <% Html.BeginForm(); %> <div> <%= Html.DropDownList(DropDownSelectList, new SelectList(
I have the following html: <div id=box> <span>stuff.....</span> </div> What i'd like to do

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.