Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML Syntax when Using Colon (:), in Tags

I am working on a mobile application and have to read a xml feed and parse the information. There it has a special tag as this <dc:creator> Jonethon Owens </dc:creator>

In C# I am using LINQ to XML and don't know how to exactly deal with this type of a tag to parse and get the information.

If someone can explain how to achieve this, really appreciated. Thanks in Advance

like image 532
JibW Avatar asked Nov 16 '11 08:11

JibW


People also ask

What is colon in XML tag?

The colons indicate that those elements are in the ns1 namespace. This is needed when you are using multiple schemas. Assuming the document only uses ns1, it is essentially equivalent to not having any "ns1:" in those tags.

How do you tag in XML?

The XML document must have start-tag, so first starting tag is known as root tag. The opening tag started with < bracket followed by tag name or element name and close with > bracket.

Does XML use tags?

XML (Extensible Markup Language) is a markup language similar to HTML, but without predefined tags to use.


1 Answers

You need the namespace prefix.

XNamespace dc = "http://purl.org/dc/elements/1.1/";


var query = from lst in XElement.Load(@"foo.xml").Elements(dc +"creator")

            select ...
like image 63
FailedDev Avatar answered Sep 20 '22 17:09

FailedDev