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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:39:55+00:00 2026-06-13T08:39:55+00:00

I have an XML document that looks like this. It may be that it’s

  • 0

I have an XML document that looks like this. It may be that it’s invalid (I didn’t create it!)

<ns:url xmlns:ns="http://www.urlone.com/" xmlns:news="http://www.urltwo.com/">
.. node tree
</ns:url>

I need to build a T-SQL Query to extract the value of the xmlns:news attribute and update it. This requires XPath. But all the queries I’ve attempted so far fail with an error similar to:

XPath expression uses unbound namespace prefix xmlns

Is is possible to select and update this node given the XML format? If so, how?

Cheers,
Matt

  • 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-13T08:39:57+00:00Added an answer on June 13, 2026 at 8:39 am

    To get the value you can use the OPENXML edge table.

    declare @XML xml = '
    <ns:url xmlns:ns="http://www.urlone.com/" xmlns:news="http://www.urltwo.com/">
    </ns:url>'
    
    declare @idoc int
    
    exec sp_xml_preparedocument @idoc output, @XML
    
    select X1.[text]
    from openxml(@idoc, '*') as X1
      inner join openxml(@idoc, '*') as X2
        on X1.parentid = X2.id
    where X2.localname = 'news' and -- Attribute name
          X2.prefix = 'xmlns' and   -- Namespace
          X2.parentid = 0           -- Attribute on root
    
    exec sp_xml_removedocument @idoc
    

    I don’t know of a way to update the URL other than recreating the XML or to use string manipulation.

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

Sidebar

Related Questions

I have an XML document that looks like this: <?xml version=1.0 encoding=UTF-8?> <xs:msgdata xmlns:xs=http://www.myCompany.com
I have an XML document that looks like this: <Data xmlns=http://www.domain.com/schema/data xmlns:dmd=http://www.domain.com/schema/data-metadata > <Something>...</Something>
I have an XML document that looks like this: <kmsg xmlns=http://url1 xmlns:env=url1 xmlns:xsi=http://www.w3.org/2001/XMLSchemainstance xsi:schemaLocation=http://location
I have an xml document that looks like this. <foo> <bar type=artist/> Bob Marley
I have an XML document that looks like this <Elements> <Element> <DisplayName /> <Type
So i have an XML document that looks like this: <?xml version=1.0 encoding=UTF-8?> <gesmes:Envelope
Why would you have a rootnode in an XML document that looks like this:
I have an xml formatted document that looks like this: <?xml version=1.0 encoding=windows-1250?> <
I have an xml document with multiple nodes that looks something like this: <Result>
I have an XML document that looks like this: <file> <name>NAME_OF_FILE</name> </file> <file> <name>NAME_OF_FILE</name>

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.