xmlns:g - base.google.com namespace problem

I found some sample code to construct an rss feed and am trying to modify it 
to match Google's specs at: http://www.google.com/base/rss_specs.html, but 
without knowing much about XML.
Their samples show the namespace declaration in the rss tag, I tried it both 
ways with the same result.

It seems reasonably clear, add a namespace:
        XmlElement docNode = rssDoc.CreateElement("rss");

        XmlAttribute attr = rssDoc.CreateAttribute("version");

        attr.Value = "2.0";

        docNode.Attributes.Append(attr);

        XmlAttribute attr1 = rssDoc.CreateAttribute("xmlns:g");

        attr1.Value = "http://base.google.com/ns/1.0";

        docNode.Attributes.Append(attr1);

        rssDoc.AppendChild(docNode);

Which produces this:

 <rss version="2.0" xmlns:g="http://base.google.com/ns/1.0">

A bit further along I attempt to use the namespace:

        workNode = rssDoc.CreateElement("g:currency");

        workNode.InnerText = thisItem.Currency;

        itemNode.AppendChild(workNode);

        workNode = rssDoc.CreateElement("g:price");

        workNode.InnerText = thisItem.Price;

        itemNode.AppendChild(workNode);

Which works fine except that it strips out the "g:" and produces this:

  <currency>USD</currency>
  <price>$20.00</price>

I In the debugger it shows g as the Prefix and currency as the LocalName and 
g:currency as Name. The default output is clearly LocalName, but it should 
be Name. How do I do it?

Kal





0
kal7998 (4)
11/29/2005 6:33:49 PM
dotnet.xml 7266 articles. 0 followers. Follow

2 Replies
521 Views

Similar Articles

[PageSpeed] 41


Kal wrote:

> I found some sample code to construct an rss feed and am trying to modify it 
> to match Google's specs at: http://www.google.com/base/rss_specs.html, but 
> without knowing much about XML.

If you want to create an element in a namespace with the DOM in .NET 
then use a namespace aware method e.g.
   rssDoc.CreateElement("prefix:localname", "namespaceURI")
or e.g.
   rssDoc.CreateElement("prefix", "localname", "namespaceURI")

If you want to create an attribute in a namespace with the DOM in .NET 
then use a namespace aware method e.g.
   elementNode.SetAttribute("localname", "namespaceURI",
"attribute value")
or e.g.
   attributeNode = rssDoc.CreateAttribute("prefix:localname", 
"namespaceURI");
   attributeNode.Value = "attribute value";
   elementNode.SetAtttributeNode(attributeNode);

You usually do not have to create xmlns attributes in the DOM as the 
serializer will add them when serializing nodes properly created as 
shown above. However if you want to add an xmlns attribute then make 
sure you use e.g.
   atttributeNode = rssDoc.CreateAttribute("xmlns:prefix", 
"http://www.w3.org/2000/xmlns/");
   attributeNode.Value = "namespaceURI";
as the namespace URI for the xmlns prefix is predefined as 
http://www.w3.org/2000/xmlns/.

-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1778)
11/29/2005 6:53:55 PM
Thanks, that worked fine.
Kal

"Martin Honnen" <mahotrash@yahoo.de> wrote in message 
news:ez9HCZR9FHA.500@TK2MSFTNGP15.phx.gbl...
>
>
> Kal wrote:
>
>> I found some sample code to construct an rss feed and am trying to modify 
>> it to match Google's specs at: http://www.google.com/base/rss_specs.html, 
>> but without knowing much about XML.
>
> If you want to create an element in a namespace with the DOM in .NET then 
> use a namespace aware method e.g.
>   rssDoc.CreateElement("prefix:localname", "namespaceURI")
> or e.g.
>   rssDoc.CreateElement("prefix", "localname", "namespaceURI")
>
> If you want to create an attribute in a namespace with the DOM in .NET 
> then use a namespace aware method e.g.
>   elementNode.SetAttribute("localname", "namespaceURI",
> "attribute value")
> or e.g.
>   attributeNode = rssDoc.CreateAttribute("prefix:localname", 
> "namespaceURI");
>   attributeNode.Value = "attribute value";
>   elementNode.SetAtttributeNode(attributeNode);
>
> You usually do not have to create xmlns attributes in the DOM as the 
> serializer will add them when serializing nodes properly created as shown 
> above. However if you want to add an xmlns attribute then make sure you 
> use e.g.
>   atttributeNode = rssDoc.CreateAttribute("xmlns:prefix", 
> "http://www.w3.org/2000/xmlns/");
>   attributeNode.Value = "namespaceURI";
> as the namespace URI for the xmlns prefix is predefined as 
> http://www.w3.org/2000/xmlns/.
>
> -- 
>
> Martin Honnen --- MVP XML
> http://JavaScript.FAQTs.com/ 


0
kal7998 (4)
11/29/2005 9:05:44 PM
Reply:

Similar Artilces:

Google Outlook Add-in
Hello I use Outlook 2007 and Vista Ultimate. I installed Google Desktop Search Outlook Addin. I then did System Restore as I did not want Google Desktop. Now everytime I open Outlook I get the following message : ' The Add-in "Google Desktop Search Outlook Addin" (C:\Program Files\Google\Google Desktop Search\GoogleDesktopOffice.dll) cannot be loaded and has been disabled by Outlook. Please contact the Add-in manufacturer for an update. If no update is available, please uninstall the Add-in. I don't know how to uninstall the Add-in. I'll be grtateful for any ...

Form printing problem
Hi all, I have a form that holds customer records which we have been printing out for filing. I put a print record command button at the top of the form and this has been working perfectly for at least the last four years printing on plain paper using auto selection on the printer. Recently the form record has started printing onto header paper. It doesn't matter whether I change the properties on the printer it keeps printing to headed paper and the only way round was to put plain paper into the headed paper tray. We have now a new printer in the office which has been set as my defa...

Problem with hyperlink
Hi, When attempting to activate a web page using a hyperlink in Excel 2003, I get a message: "Opening"javascript:OWSize ("PR_Popup",http://racingpost.co.uk/horses/trainer_form.sd?trainer_id=693&code=Flat,620,480,'no','yes','yes')" Hyperlinks can be harmful to your computer data. To protect your computer, click only those hyperlinks from trusted sources. Do you want to continue. YES NO When I click YES a web page appears for a split second and then closes. I turned off Pop up blocker but this did not solve the problem. Why am I havi...

Removing xmlns:xsd and xmlns:xsi when using ImportNode
I'm doing some document merging where I want to bring in an XmlDocument and import its document element into another document deeper in its tree. However, when serializing my underlying objects, .Net likes to add these namespaces: <RootNode xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ChildNode xmlns="MyObjectHierarchyNamespace/> </RootNode> The problem this is causing me is that any node(s) that have those namespaces get properly imported into the XML, but those nodes fail to dese...

Problem - Extension SMTP
Hi, I have a problem: when I open IMS Properity show the message:Extension SMTP could not be loaded. The specyfied module could not be found. Microsoft Windows NT ID no: 0xc002007e. What I must do whit this problem? Thanks for help Hi, Try this: http://support.microsoft.com/default.aspx?scid=kb;en-us;186787 Regards, Tim "still" wrote: > Hi, I have a problem: when I open IMS Properity show the > message:Extension SMTP could not be loaded. The specyfied module could > not be found. Microsoft Windows NT ID no: 0xc002007e. > What I must do whit this problem? > Tha...

Excel Font Problem
Every time I enter a number <1 into my Excel worksheet, it prints in white which is too hard to see. I have the font set at black. How do I get ALL the numbers to print in black One thing to possibly check: 1. Tools > Options > Color and try Reset. HTH Select those cells and see what Format>Conditional Formattting reveals. Sounds like you have a setting that whites the font on values <1 Gord Dibben Excel MVP On Thu, 30 Jun 2005 08:09:04 -0700, Heather S <Heather S@discussions.microsoft.com> wrote: >Every time I enter a number <1 into my Excel worksheet, ...

Activity report that shows all g/l entries during a given time
Hi, My users are looking for a report that shows all journal entries during the month of may. The current reports are geared towards the g/l posting times, not the user activities. In general, for our auditors, we are looking to provide a report that shows all entries done by users for a given time frame? Does anyone know whether this report exists? I haven't been able to find it directly. Or use a smart list... I've looked at account transactions but none of the date fields match the date the user posted. It has the posting date... but not the date when the user...

newsgroup problems
Hello Suddenly I am not able to get onto the newsgroup I use. I am given the following message: Windows Mail was unable to switch to the newsgroup 'uk.sci.weather' on the server 'news.virginmedia.com' 480 Authentication Required. Does anyone know what this means and how do I get back onto the newsgroup please? Trevor Smith It means exactly what it says: Authentication Required. Contact your ISP. trevor wrote: > Suddenly I am not able to get onto the newsgroup I use. I am given the > following message: > > Windows Mail was unable to ...

counter problem(you really want to read this)
i have a workbook that contains two sheets. Sheet one contains a list of names. Each name references an information sheet for that name. I wish to collect data for each name for a specified number of days "x". When that number of days is met, then I wish to click on a button on the toolbar to delete some number "x" of days of data from 1 - "x" including "x". I wish to do this to make the data more current hence meaningful ...

Moving Mailboxes problem?
1. We have a Domain server running Win 2k Sp4. 2. We have Ex 5.5 Sp4 installed on a Win 2k Sp4 Server. 3. We have done a fresh install of 2003 Server on a new server, and then a fresh install of Exchange 2003. Once this is running properly, we want to move the mailboxes from the 5.5 to the 2003 exchange server. 4. I set up the Active Directory connector on the 2003 server, and it is running a 2 way connection between the Domain server and the 5.5 server, using the default LDAP port 389. It is replicating to the default objects (Active Directory users > Exchange Recients both ways) 5...

Why isn't OL2007 e-mail more like Google Mail?
I had a look at a friend's Google Mail Inbox the other day, and it's really impressive. E-mails are automatically grouped by conversation. Better still, when you read one message, the others in the thread appear as popup tabs above and below it, which you can enlarge or reduce with one click. It's truly cool. (Outlook can't do this unless you create a special search folder, and then that doesn't work very well.) Then Google Mail automatically removes the rest of the thread which you don't want cluttering the window and replaces it with 'Show quoted text...

IHTMLDocument Load problem #2
Let me explain my problem first ! I want to load a HTML file into IHTMLDocument. So I used IPersistFile and it's methods. My problem is that it loads only small HTML files. For large HTML files , it loads it partially. I have called SaveHTMLDocument function (this is my function which saves HTML document to disk file using IPersistFile ) to check that is the document loaded entirely. My friends told me that document loads asnchronously ..thats why you are facing this problem. I put one while loop checking ready state of document , but it shows me "loading" state each time and do...

Conditional Formatting problem #4
I would like a cell to have a background color of yellow if it is empty (ie: neeeds data input). Once it has data, the background turns off. I used two conditions in the conditional format command and it doesn't appear to be working. I used (cell value) (is equal to) then typed in 2 double quotes with no space in between for the condition "yellow" then, condition 2 (cell value) (is not equal to) then typed in the same as above for the condition "no fill" I thought it seemd simple enough and it appeared to work at first but then stopped working. How do you guy...

Problem with VBScript Running on Custom Home Page
I've got the following sub that is intended to open a new Explorer and display the specified folder. It works on my home laptop but when I try to use it on a machine connected to Exchange it craps out. The problem appears to be at this line where the object is not being instantiated. Any Ideas? [set objNamespace = objOutlook.GetNamespace("MAPI")] sub displayFolder(sourceObject) 'Display the folder in a new Explorer window set objOutlook = ObjectCenterTopOutlookViewControl.outlookApplication set ovc = document.getElementById(sourceObject) &...

RMA Return G/L Posting
When a Cross-Ship RMA is received, it creates a SOP Return document. Where is the Sales Returns G/L account number pullled from? We have a whole bunch of Returns, posted in October through present, that have posted to totally unrelated G/L accounts. Actually, there are three different asset accounts that were used for the Debit account. It appears that our Posting Accounts setup is correct, as well as the posting accounts assigned to the Items and/or Item Classes. Any ideas? Is there any RMA file maintenance that we should run? "Elaine" wrote: > When a Cross-Ship RMA ...

How:spinbutton to display negative integers(e.g. range -10 to 10)
I have created a spinbutton and set min and max to -10 and 10 intending yield a range but clicking down from 0 gives me 65535.00. That's because you can't set the linked cell property <0, you would need code for this -- Regards, Peo Sjoblom "Boris" <Boris@discussions.microsoft.com> wrote in message news:978E6420-048D-449E-81E6-21E0BBB31409@microsoft.com... > I have created a spinbutton and set min and max to -10 and 10 intending yield > a range but clicking down from 0 gives me 65535.00. > Oops! here's the code, be in design mode and double ...

Strange problem with the Price lists
Hi all: I have a product named A, ok? This product appears in 3 lists Price list 1, Price 100 price list 2, price 200 Price list 3 , price 300 In this scenario, I shouldn't need to define a default price list, right? Well, it happens that if a default price list is not defined, then the product doesn't appear in any on the Price lists.... Any ideas? Alejandro Leguizamo SQL Server MVP Colombia ...

Wrong usage of xmlns?
Hi I need to integrate to a system that has XML like this: <Calls xmlns="\\SomeMachine\Share\Schemas\Calls1_2.dtd" Version="1.2"> <Call> <CallRef>Call1</CallRef> <UserRef>286</UserRef> <Details> <Condition>EDITTABLE</Condition> <CallType>Water Damage</CallType> <Select0>Water Damage</Select0> <Select1>386 Kentmore Road</Select1> <Select2>DE56 1UU</Select2> <Select3>Fairly Urgent</Select3> </Details> <Defaults> </Defaults> <Panels> </P...

Website browsing problem
Hi All We have an engineering client who cannot connect to one particular website www.schydraulic.com Client network setup: SBS 2003 Premium, ISA 2004, 2 nics. Internet--->Ext nic 192.168.0.2-->Int nic 192.168.16.2--->Internal network Client installation was carried out over 3 years ago and they have had no other browsing issues except this one website they have only recently neededaccess to. Cannot connect to this site from any workstation or SBS server. We have another client who has an identical SBS setup and they can access this website. I have setup lo...

Filtering messages from mydomain.com to mydomain.com if the originator's IP doesn't match my IP block
Can I do that in Exchange 2000/2003 and, if so - how? Thanks! You can do it on exchange 2003, by enabling sender id. see http://www.petri.co.il/configuring_sender_id_in_exchange_sp2.htm "Fritz" <fritz@dontbite.com> wrote in message news:uShKcMfIGHA.3144@TK2MSFTNGP10.phx.gbl... > Can I do that in Exchange 2000/2003 and, if so - how? > > Thanks! > > After Uninstalling/Reinstalling IMF, the Sender ID tab is missing from the global message delivery options in ESM. How do I get it back? Thanks! "Tom Felts" <tfelts@nospam.mckennalong.com>...

Greeting card problem
I want to make a greeting card with 4 pages (front, inside left, inside right, back) such that I can print two cards on an A4 sheet of paper. So far I have only been able to print one card on an A4 sheet, by printing all four pages on one side of an A4 sheet and then folding it twice to make a card with the pages in the right place. This is fine if using 80g/m2 paper, but I would like to use the heavier 160g/m2 paper (or even photographic paper), and only have to fold the card once, otherwise it is too bulky. I assume I'll have to print pages 4 and 1 on one side, and pages 2 and 3 ...

Howto: Ommit empty xmlns specs?
Hi, I generate Xml with the XmlDocument methods. Now I have the problem, that a node has a namespace declaration but the child text nodes shall not have a namespace specification. The XML should look as follows: <root xmlns="anyURI"> <child 1>My Text</child 1> ... But when generation the XLM, the nodes look like that: <root xmlns="anyURI"> <child 1 xmlns="">My Text</child 1> How can I suppress the xmlns="" in child 1 ??? Thanks for any help! Regards, hd ..PS: C#, VS2005 Generation like this...

If you haven't tried finance.google
http://finance.google.com/finance?q=msft&hl=en or http://finance.google.com/finance?cid=13756934 Very nice charts - can slide along graph line for price on any given day. Slide the tab on tab to adjust date. On Thu, 11 May 2006 13:50:56 -0400, "- Bobb -" <bobb@netscape.net> wrote: >http://finance.google.com/finance?q=msft&hl=en >or >http://finance.google.com/finance?cid=13756934 > >Very nice charts - can slide along graph line for price on any given >day. Slide the tab on tab to adjust date. I tried Google finance. Updates too slowly. I can ge...

File send send Link by Email problems in IE after Thunderbird Install
I have installed Thunderbird and have been very pleased with it. I only use Thunderbird at the moment to keep all my RSS feeds that I use. I still use IE as my default browser but the problem I have now is trying to send a URL via email through the IE. On IE if you go to File>Send>Link by Email it always launches Thunderbird. I do not want this to happen, I want it to launch Outlook as it normally did. I have reset the settings in Internet options to their default and it still makes no difference. I do not use Thunderbird as my default mail client. Any ideas how to get Outlook to launc...

Local Data synchronisation problem
Hello, I have a strange problem when I try to syncronize Outlook and CRM using the local data option. The first time that I have syncronize Outlook and CRM everything work fine and no problem appear. The CRM Contact appear inside the Outlook contact. But don't ask me why, I have delete all contact inside my Outlook (but don't forget all contact are always inside the CRM). After this, I try to syncronize again Outlook and CRM but this time no contact appear inside the Outlook. Someone have an idea how can I fix this ? P.S.: My Outlook use an Exchange server and the Outlook d...