Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello friends

Can you please help me to create this document with XDocument,XElement i mean by LINQ. The problem i am facing is the intermediate tags with colon.

<rss xmlns:g="http://base.google.com/ns/1.0" xmlns:receipt="urn:receipt">
<channel>
<item>
<g:id></g:id>
<g:google_product_category />
<g:image_link>
</g:image_link>
</item></channel></rss>
Posted
Updated 29-Oct-13 9:16am
v5
Comments
OriginalGriff 28-Oct-13 7:21am    
DON'T SHOUT. Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalisation if you want to be taken seriously.
somnath roy24 28-Oct-13 7:24am    
Ok
somnath roy24 29-Oct-13 15:17pm    
Please Help Friends....
johannesnestler 30-Oct-13 12:52pm    
solved?

1 solution

Hi somnath roy24,

so you need something like this?

C#
XNamespace g = "http://base.google.com/ns/1.0";
XElement rss = XElement.Parse(@"<rss xmlns:g=""http://base.google.com/ns/1.0"" xmlns:receipt=""urn:receipt""> </rss>");           
            rss.Add(new XElement("channel",
                new XElement("item",
                    new XElement(g + "id"),
                    new XElement(g + "google_product_category"),
                    new XElement(g + "image_link"),
                    new XElement(g + "image_link")
                    )));


The "+" operator is overloaded for XNamespace...
 
Share this answer
 
v2
Comments
johannesnestler 29-Oct-13 16:12pm    
thank you Matt T Heffron for editing - just wanted to change it but you were faster...
Valery Possoz 29-Oct-13 16:32pm    
simple and easy :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900