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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:31:36+00:00 2026-05-24T13:31:36+00:00

Possible Duplicate: A simple program to CRUD node and node values of xml file

  • 0

Possible Duplicate:
A simple program to CRUD node and node values of xml file

I have a string (for example $output) with html code containing multiple tags and text. I need to lookup for all ID tags:

<id>123456</id>

and change them to:

<id>123456</id><url>www.webpage.com/somepage.php?id=123456</url>

As you can see the new tag is created and added after ID tag.
Webpage url address is stored in string $url_adr. ID number is always different in each ID tag. And there is multiple ID tags in string, so it needs to be changed one by one
I need this code in PHP. Thanks a lot….

  • 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-24T13:31:37+00:00Added an answer on May 24, 2026 at 1:31 pm

    In simple cases like this, you can do it with a regular expression replace:

    $output = '<id>123456</id>';
    $url_adr = 'www.webpage.com/somepage.php?id=';
    preg_replace('~<id>(.*?)</id>~i', '<id>$1</id><url>'.$url_adr.'$1</url>', $output);
    

    But if you need anything more complicated or full featured, you’d better take a look at proper XML parsers.

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

Sidebar

Related Questions

Possible Duplicate: String vs string in C# I have a simple scenario where I
Possible Duplicate: Why does simple C code receive segmentation fault? I am working in
Possible Duplicate: Simple PHP Mailer Script i run a small website and we have
Possible Duplicate: Simple way to determine if string is only characters, or to check
Possible Duplicate: What is a simple example of floating point/rounding error? When I execute
Possible Duplicate: Where do I find the current {X} standard? I have a simple
Possible Duplicate: Convert std::string to const char* or char* Simple question but I'm new
Possible Duplicate: simple DataGridView refresh question I have a mainForm which has a DataGridView
Possible Duplicate: simple deadlock example in c# I've been dealing with multithreading in my
Possible Duplicate: Is there a simple script to convert C++ enum to string? In

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.