473,587 Members | 2,466 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I prefix attributes with a namespace?

I need to create xml like the following:
<item mynamespace:nam e="MyName" mynamespace:age ="100" />

I am using code similar to this:
XmlDocument meegoInfo = _LoadTemplateXm l("Avatar");

// Create downlevel item
XmlNode node= xmlDoc.Document Element;
XmlElement item = xmlDoc.CreateEl ement("item");
item.SetAttribu te("name", "MyName");
item.SetAttribu te("age", "100");
node.AppendChil d(item);

Cheers,

Sam-I-Am
Nov 16 '05 #1
1 3052
Then you will need to use XmlAttribute rather than SetAttribute.
You will need to associate an URI with the namespace prefix.

XmlAttribute a = [XmlDocument].CreateAttribut e
("mynamespac e", "name", "http://ourcompany.com/mynamespace/");
[XmlNode].Attributes.App end(a);

--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Sam-I-Am" <sa****@3hgroup .com> wrote in message
news:eD******** ******@tk2msftn gp13.phx.gbl...
I need to create xml like the following:
<item mynamespace:nam e="MyName" mynamespace:age ="100" />

I am using code similar to this:
XmlDocument meegoInfo = _LoadTemplateXm l("Avatar");

// Create downlevel item
XmlNode node= xmlDoc.Document Element;
XmlElement item = xmlDoc.CreateEl ement("item");
item.SetAttribu te("name", "MyName");
item.SetAttribu te("age", "100");
node.AppendChil d(item);

Cheers,

Sam-I-Am

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1179
by: Ajay | last post by:
hi! for the XML <appel:RULESET xmlns:appel="http://www.w3.org/2001/02/appelv1" xmlns:p3p="http://www.w3.org/2000/12/p3pv1"> <appel:RULE prompt="no"> <p3p:POLICY> <p3p:ACCESS appel:connective="non-and"> <p3p:all/> </p3p:ACCESS>
4
12153
by: AP | last post by:
Hi, I have a class that I wish to serialize to XML, part of which looks like this: public class TitleNotification { public string NoNameSpaceSchemaLocation = http://www.pdr.com\nhttps://extw3c.pdr.com/prism/b2b/schemas/TitleNotification.xsd;
6
2575
by: Martin | last post by:
Hi, I have a xml file like the one below <?xml version="1.0" encoding="utf-8"?><e1 xmlns:e1="http://tempuri.org/Source1.xsd" e1:att1="1" e1:att2="2" e1:rest="345"/> If I try to create a schema for it with Visual Studio, I get the error "Failed to create a schema for this data file because:
1
1085
by: David Thielen | last post by:
Hi; I am creating an XmlDocument (.net 2.0) and then saving it. I need the final xml file to look as follows (SpreadsheetML schema - I have no control over it): <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:ss="schemas-microsoft-com:office:spreadsheet">
0
879
by: heidi | last post by:
Hello, how can I find association between tag prefix and namespace programatically? I have .aspx page with @Register directive and want to check if tag prefix points to desired namespace. Is there some collection of all registered namespaces (assemblies) where that could be checked?
3
27047
by: Andy Fish | last post by:
Hi, I am creating a new XmlDocument from scratch, but I can't see how I can make a namespace declaration and associate a prefix with it. For instance in the following example: XmlDocument doc = new XmlDocument(); XmlElement el = doc.CreateElement("foo:data"); doc.AppendChild(el); doc.Save("foo.xml");
18
7720
by: jacksu | last post by:
I have a simple program to run xpath with xerces 1_2_7 XPathFactory factory = XPathFactory.newInstance(); XPath xPath = factory.newXPath(); XPathExpression xp = xPath.compile(strXpr); System.out.println(xp.evaluate(new InputSource(new FileInputStream("a.xml"))));
5
2617
by: asciz | last post by:
Hi I'm having a problem with an XML file, most likely because of my lack of understanding of XML schemas I have the following XML file: <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
10
3583
by: Andy Fish | last post by:
hi, I have an XSLT which is producing XML output. many of the nodes in the output tree contain namespace declarations for namespaces that are used in the source document even though they are not used in the result document or the stylesheet also I find that (for namespaces that are referenced in the stylesheet) even if I put an explicit namespace declaration on the root element of the result
0
7854
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8219
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7978
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6629
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5395
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3845
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.