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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:53:39+00:00 2026-05-13T16:53:39+00:00

how can i add namespace name before a attribute of newly created tag,like <Data

  • 0

how can i add namespace name before a attribute of newly created tag,like

<Data ss:Type="String">this the value of data</Data>

but can create only

<Data Type="String">this the value of data</Data>

so i can not add “ss:” before atttbute.

Thanks in Advance

Have Dream Day

  • 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-13T16:53:40+00:00Added an answer on May 13, 2026 at 4:53 pm

    In the SimpleXml PHP manual someone gave a good example in the comments section.

    Here is how I got it to work.

    Say you have the following XML in a file xml.php:

    <?php
    $string = <<<XML
    <Row>
      <Cell>
        <Data>Dolly Parton</Data>
      </Cell>
      <Cell>
        <Data>Islands in the Stream</Data>
      </Cell>
      <Cell>
        <Data>what</Data>
      </Cell>
      <Cell>
        <Data>1-29-2010</Data>
      </Cell>
    </Row>
    XML;
    

    You can read in this file and add the attributes you want by using XPath.

     <?php 
            include("xml.php"); 
    
            $sxe = new SimpleXMLElement($string);
    
            $data = $sxe->xpath('//Data');
    
        foreach ($data as $value)
        {
            $value->addAttribute('ss:Type', 'String', 'http://www.w3.org/2001/XMLSchema-instance'); 
            }
    
            echo $sxe->asXML();
    
        ?>
    

    This is the output I get:

    <Row>
      <Cell>
        <Data xmlns:ss="http://www.w3.org/2001/XMLSchema-instance" ss:Type="String">Dolly Parton</Data>
      </Cell>
      <Cell>
        <Data xmlns:ss="http://www.w3.org/2001/XMLSchema-instance" ss:Type="String">Islands in the Stream</Data>
      </Cell>
    
      <Cell>
        <Data xmlns:ss="http://www.w3.org/2001/XMLSchema-instance" ss:Type="String">what</Data>
      </Cell>
      <Cell>
        <Data xmlns:ss="http://www.w3.org/2001/XMLSchema-instance" ss:Type="String">1-29-2010</Data>
      </Cell>
    </Row>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can't include Microsoft.Security.Application using Microsoft.Security.Application; Gives this error: The type or namespace name
Helllo, I get this error: CS0246: The type or namespace name 'DataClasses1DataContext' could not
I got many exceptions like: Error 95 The type or namespace name 'Web' does
Users on my site can add nodes of a custom type (let's call it
The type or namespace name 'Resources' does not exist in the namespace 'MyWebProject.Web' (are
Within my project I have gotten this error: Error 1 The type or namespace
Is it possible (and how) to add the namespace in the name of the
I keep on getting: The type or namespace name 'Mvc' does not exist in
I'm not sure if namespaces are required for valid/correct XML. Can I add arbitrary
Ruby can add methods to the Number class and other core types to get

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.