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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:25:18+00:00 2026-05-14T19:25:18+00:00

I have a document created in a constructor, and during execution I’m filling it

  • 0

I have a document created in a constructor, and during execution I’m filling
it in with fragments generated from Custom Business Objects.

When I’m outputting the fragments, I need to include namespace fragments, but
I’d like to avoid adding the namespace url to each fragment, since it’s defined in the root.

Any thoughts?

_doc = new XDocument(
            new XDeclaration("1.0", "UTF-8", "yes"),
            new XElement(aw + "kml",
                new XAttribute(XNamespace.Xmlns + "gx", "http://www.google.com/kml/ext/2.2"),
                new XAttribute("xmlns", "http://www.opengis.net/kml/2.2"),
                new XElement(aw+"Document",

That’s how the doc starts, so the namespaces are there.
How do I go about building an XElement to add using the gx prefix?

  • 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-14T19:25:18+00:00Added an answer on May 14, 2026 at 7:25 pm

    Use the same URI for an XNamespace:

    XNamespace gx = "http://www.google.com/kml/ext/2.2";
    XElement foo = new XElement(gx + "foo");
    

    LINQ to XML will use the appropriate prefix automatically, as I understand it.

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

Sidebar

Related Questions

I have a DOM Document created from scratch and I need to serialize it
this is my situation: I have two org.w3c.dom.Document created from two xml files. What
I have a report document created by Microsoft Reporting but instead of using its
I have an XML document as follows: <directory> <file><monitored>0</monitored> <xferStatus>1</xferStatus> <name>test1.txt</name> <size>7</size> <created>03/31/10 11:30:02
I have created an Excel document using OpenXml SDK 2.0, now I have to
I have created a xslt document which formats an xml document, but I would
I have written a xml/php document that is pulling from a Magento Commerce database,
I have used this code in my AS3 document class to remove all objects
I have created some documents and managed to make some simple queries but I
I have existing java code and need to create Design Document based on that.

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.