No response in AG-Softwate MatriX - c#

I am developing a IM by AG-Softwate MatriX and I want to achieve the login opertion, however when I use xmppClient.open(), I can't receive the xml stream that help me to accept the certificate.
this is the xml I have sended or received or output in console:
send:<stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="dodo.com" version="1.0" >
rec:<stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" id="2543867956" from="dodo.com" version="1.0" xml:lang="en" >
'vivid.vshost.exe' (CLR v4.0.30319: vivid.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.resources\v4.0_4.0.0.0_zh-Hans_b77a5c561934e089\System.resources.dll'. Module was built without symbols.
rec:<stream:features xmlns:stream="http://etherx.jabber.org/streams">
<starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls" />
<mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
<mechanism>PLAIN</mechanism>
<mechanism>DIGEST-MD5</mechanism>
<mechanism>SCRAM-SHA-1</mechanism>
</mechanisms>
<c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://www.process-one.net/en/ejabberd/" ver="k0acyvEdZQ7cl5uD5FTPoiOnuaw=" />
<register xmlns="http://jabber.org/features/iq-register" />
</stream:features>
send:<starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls" />
rec:<proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls" />
I don't know why my program have not sended the rest xml, and you can see the right xml stream:
SEND: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="dodo.com" version="1.0" >
RECV: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" id="3880372647" from="dodo.com" version="1.0" xml:lang="en" >
RECV: <stream:features xmlns:stream="http://etherx.jabber.org/streams">
<starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls" />
<mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
<mechanism>PLAIN</mechanism>
<mechanism>DIGEST-MD5</mechanism>
<mechanism>SCRAM-SHA-1</mechanism>
</mechanisms>
<c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://www.process-one.net/en/ejabberd/" ver="k0acyvEdZQ7cl5uD5FTPoiOnuaw=" />
<register xmlns="http://jabber.org/features/iq-register" />
</stream:features>
SEND: <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls" />
RECV: <proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls" />
SEND: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="dodo.com" version="1.0" >
RECV: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" id="2091441686" from="dodo.com" version="1.0" xml:lang="en" >
RECV: <stream:features xmlns:stream="http://etherx.jabber.org/streams">
<mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
<mechanism>PLAIN</mechanism>
<mechanism>DIGEST-MD5</mechanism>
<mechanism>SCRAM-SHA-1</mechanism>
</mechanisms>
<c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://www.process-one.net/en/ejabberd/" ver="k0acyvEdZQ7cl5uD5FTPoiOnuaw=" />
<register xmlns="http://jabber.org/features/iq-register" />
</stream:features>
SEND: <auth mechanism="SCRAM-SHA-1" xmlns="urn:ietf:params:xml:ns:xmpp-sasl">biwsbj1pbWFjLHI9NmJkdG40NWdGbTNoYWJIR3JpdGdnOUdqT21yUDU0alA=</auth>
RECV: <challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl">cj02YmR0bjQ1Z0ZtM2hhYkhHcml0Z2c5R2pPbXJQNTRqUGFqRWRPa0hKUGRCczl4aWMxN3lSeXc9PSxzPWowdHhSY0pnY0FaUkdYcnpCMUJydmc9PSxpPTQwOTY=</challenge>
SEND: <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">Yz1iaXdzLHI9NmJkdG40NWdGbTNoYWJIR3JpdGdnOUdqT21yUDU0alBhakVkT2tISlBkQnM5eGljMTd5Unl3PT0scD0weDZXcFJ1WG0vQzF5a3JIUXA1c2lBS2lpbzA9</response>
RECV: <success xmlns="urn:ietf:params:xml:ns:xmpp-sasl">dj1CRitFMkdhcVZLYlRVeHpLbWxwVG82YVpDZzQ9</success>
SEND: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="dodo.com" version="1.0" >
RECV: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" id="3562760347" from="dodo.com" version="1.0" xml:lang="en" >
RECV: <stream:features xmlns:stream="http://etherx.jabber.org/streams">
<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind" />
<session xmlns="urn:ietf:params:xml:ns:xmpp-session" />
<sm xmlns="urn:xmpp:sm:2" />
<sm xmlns="urn:xmpp:sm:3" />
<c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://www.process-one.net/en/ejabberd/" ver="k0acyvEdZQ7cl5uD5FTPoiOnuaw=" />
<register xmlns="http://jabber.org/features/iq-register" />
</stream:features>
SEND: <iq id="MX_1" type="set" xmlns="jabber:client">
<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind">
<resource>MatriX</resource>
</bind>
</iq>
RECV: <iq id="MX_1" type="result" xmlns="jabber:client">
<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind">
<jid>imac#dodo.com/MatriX</jid>
</bind>
</iq>
SEND: <iq id="MX_2" type="set" xmlns="jabber:client">
<session xmlns="urn:ietf:params:xml:ns:xmpp-session" />
</iq>
RECV: <iq type="result" id="MX_2" xmlns="jabber:client" />
SEND: <iq id="MX_3" type="get" xmlns="jabber:client">
<query xmlns="jabber:iq:roster" />
</iq>
RECV: <iq from="imac#dodo.com" to="imac#dodo.com/MatriX" id="MX_3" type="result" xmlns="jabber:client">
<query xmlns="jabber:iq:roster">
<item subscription="both" jid="test2#dodo.com">
<group>EveryBody</group>
</item>
<item subscription="both" jid="123456#dodo.com">
<group>EveryBody</group>
</item>
<item subscription="both" jid="macbook#dodo.com">
<group>EveryBody</group>
</item>
<item subscription="both" jid="123457#dodo.com">
<group>EveryBody</group>
</item>
<item subscription="both" jid="test3#dodo.com">
<group>EveryBody</group>
</item>
<item subscription="both" jid="admin#dodo.com">
<group>EveryBody</group>
</item>
<item subscription="both" jid="test4#dodo.com">
<group>EveryBody</group>
</item>
<item subscription="both" jid="yj#dodo.com">
<group>EveryBody</group>
</item>
<item subscription="both" jid="test#dodo.com">
<group>EveryBody</group>
</item>
<item subscription="both" jid="yuanjiong#dodo.com">
<group>EveryBody</group>
</item>
<item subscription="both" jid="taojiaen#dodo.com" />
<item ask="subscribe" subscription="none" jid="taojiaen#163.com" />
</query>
</iq>
SEND: <presence xmlns="jabber:client">
<status></status>
<priority>0</priority>
</presence>
RECV: <presence from="imac#dodo.com/MatriX" to="imac#dodo.com/MatriX" xmlns="jabber:client">
<status />
<priority>0</priority>
</presence>
As you can see I have lost a lot of stream because My program have not sended the right xml
please help me to find the bug.
this my code:
Config.NowXmppClient = new XmppClient();
Config.NowXmppClient.ResolveSrvRecords = false;
Config.NowXmppClient.SetXmppDomain("dodo.com");
Config.NowXmppClient.Hostname = "123.456.789s.130";
Config.NowXmppClient.Port= 5222;
const string LIC = #"eJxkkN1SgzAQhV+l470GHLXF2WZEpS2lYv+o08sIMUITAiGxwNPb2vp/s7O7
357dMwuTNKZ5RTu14HnVPyHstJIveksUveYHdIJhqmRiYu0neKFNkkpA3x2Y
GZLrVDfYBvSVw52ptBRUYQiJoNh7I9wQLRWgjxrupChI3nyCVOadoxVAnww8
QVKOK8JpdfPD2VmyGzqw3fDXoahIiKZeXaSK3u8yfG7Zl5ZjOYD+IfCreyok
1srsdh0L2Mff+gvb2uv/AFikLCfaKIq35cOwPb/yeMzasW8PMgcNuugqKpdW
MvBcq5mVt2vCellMrWw+Cdcuvy2WZIOcyaj2h342DcLQsdeBiJpX/mAHw17j
luEsImbKFs9hN2rV8Ok1HhdSsMA1o27LWW81mjxS/+V5U69UvSAoq5mTuyNn
Gyg2d8vHplHzrvZNQthyI9SgzcdP2z6gb9+A7wI=";
Matrix.License.LicenseManager.SetLicense(LIC);
Config.NowXmppClient.OnReceiveXml += new System.EventHandler<Matrix.TextEventArgs>(this.xmppClient_OnReceiveXml);
Config.NowXmppClient.OnSendXml += new System.EventHandler<Matrix.TextEventArgs>(this.xmppClient_OnSendXml);
//Config.NowXmppClient.OnStreamError += new System.EventHandler<Matrix.StreamErrorEventArgs>(this.xmppClient_OnStreamError);
Config.NowXmppClient.OnValidateCertificate += new System.EventHandler<Matrix.CertificateEventArgs>(this.xmppClient_OnValidateCertificate);
Config.NowXmppClient.OnLogin += new System.EventHandler<Matrix.EventArgs>(this.xmppClient_OnLogin);
private void xmppClient_OnValidateCertificate(object sender, CertificateEventArgs e)
{
// always accept cert
e.AcceptCertificate = true;
StackFrame[] stacks = new StackTrace().GetFrames();
Console.Write(ToString(stacks));
// or let the user validate the certificate
// ValidateCertificate(e);
}
private void xmppClient_OnLogin(object sender, Matrix.EventArgs e)
{
Console.WriteLine("OnLogin");
}
private void xmppClient_OnReceiveXml(object sender, TextEventArgs e)
{
Console.WriteLine("rec:" + e.Text);
}
private void xmppClient_OnSendXml(object sender, TextEventArgs e)
{
Console.WriteLine("send:" + e.Text);
}
anyone help!

looks like there is a problem with your TLS server certificate.
Try to install a proper server certificate or try to connect without TLS
Config.NowXmppClient.StartTls = false;

Related

How do I write fragmented xml file without root element?

I got fragmented xml file (document without root element/node):
<?xml version="1.0" standalone="no" ?>
<WndPos name="Login" l="703" r="1264" t="323" b="909" />
<WndPos name="Main" l="703" r="768" t="323" b="609" />
<LayerManager />
<ViewLayers name="Roof" roof="1">
<Layer level="1" visible="1" />
</ViewLayers>
<DirProfiles>
<ProfileInfo ProfileName="Control" DatabasePath="D:\Database\Control" />
</DirProfiles>
<DirHistory>
<ProfileInfo Use="Database" Path="D:\Database\Control" />
</DirHistory>
I am reading this file using the following:
string xmlPath = Environment.GetEnvironmentVariable("USERPROFILE") + "\\my.xml";
XmlReaderSettings settings = new XmlReaderSettings();
settings.ConformanceLevel = ConformanceLevel.Fragment;
XDocument doc = new XDocument(new XElement("root"));
XElement root = doc.Descendants().First();
using (StreamReader fs = new StreamReader(xmlPath))
using (XmlReader xr = XmlReader.Create(fs, settings))
{
while(xr.Read())
{
if (xr.NodeType == XmlNodeType.Element)
{
root.Add(XElement.Load(xr.ReadSubtree()));
}
}
}
Later on I change <DirProfiles>...</DirProfiles> section and getting the following data:
<?xml version="1.0" standalone="no" ?>
<WndPos name="Login" l="703" r="1264" t="323" b="909" />
<WndPos name="Main" l="703" r="768" t="323" b="609" />
<LayerManager />
<ViewLayers name="Roof" roof="1">
<Layer level="1" visible="1" />
</ViewLayers>
<DirProfiles>
<ProfileInfo ProfileName="Control1" DatabasePath="D:\Database\Control1" />
<ProfileInfo ProfileName="Control2" DatabasePath="D:\Database\Control2" />
<ProfileInfo ProfileName="Control3" DatabasePath="D:\Database\Control3" />
<ProfileInfo ProfileName="Control4" DatabasePath="D:\Database\Control4" />
<ProfileInfo ProfileName="Control5" DatabasePath="D:\Database\Control5" />
</DirProfiles>
<DirHistory>
<ProfileInfo Use="Database" Path="D:\Database\Control" />
</DirHistory>
This result xml fragment I have to write to the file which should be fragmented xml file (without root element).
I tried to do the following:
doc.Save();
But it saves with root element and application can't work with this xml.

How to write xpath for xml with two namespaces?

I am trying to get the values of the title and link with the attribute equals to alternate. But with the namespaces, I find it a bit challenging to get the values.
I have added my namespaces as follows but my result is comming back with Enumeration yeilds no result:
nameSpaceManager_ = new XmlNamespaceManager(new NameTable());
nameSpaceManager_.AddNamespace("viz", "http://www.vizrt.com/atom");
nameSpaceManager_.AddNamespace("atom", "http://www.w3.org/2005/Atom");
I am using XDocument with a mixture of linq and xpath to query my data.
I use the XPath as follows:
var showName = showNode.XPathEvaluate("/atom:entry/atom:title/text()", nameSpaceManager_);
UPDATE
XML:
<?xml version="1.0" encoding="UTF-8"?>
<feed xml:base="http://127.0.0.1:8580/directory/shows/" xmlns="http://www.w3.org/2005/Atom">
<entry xmlns="http://www.w3.org/2005/Atom"
xmlns:viz="http://www.vizrt.com/atom">
<title>My Show</title>
<author>
<name>Media Sequencer</name>
</author>
<id>tag:user,2017-02-03:0:/directory/shows/My%20Show.show</id>
<updated>2017-02-03T11:41:05Z</updated>
<summary>Show My Show</summary>
<category scheme="http://www.vizrt.com/types" term="directory" />
<category scheme="http://www.vizrt.com/types" term="show" />
<category scheme="http://www.vizrt.com/types" term="trio_4_layer_collection" label="Trio 4 Layer Collection" />
<link type="application/atom+xml;type=feed" rel="alternate" href="http://127.0.0.1:8580/show/%7B4575C71F-FC79-4813-A92F-D6297D5C517C%7D/" />
<link type="application/atom+xml;type=entry" rel="self" href="http://127.0.0.1:8580/directory/shows/My%20Show.show" />
<viz:empty>false</viz:empty>
</entry>
<entry xmlns="http://www.w3.org/2005/Atom"
xmlns:viz="http://www.vizrt.com/atom">
<title>My Show 2</title>
<author>
<name>Media Sequencer</name>
</author>
<id>tag:user,2017-02-03:0:/directory/shows/My%20Show.show</id>
<updated>2017-02-03T11:41:05Z</updated>
<summary>Show My Show</summary>
<category scheme="http://www.vizrt.com/types" term="directory" />
<category scheme="http://www.vizrt.com/types" term="show" />
<category scheme="http://www.vizrt.com/types" term="trio_4_layer_collection" label="Trio 4 Layer Collection" />
<link type="application/atom+xml;type=feed" rel="alternate" href="http://127.0.0.1:8580/show/%7B4575C71F-FC79-4813-A92F-D6297D5C517C%7D/" />
<link type="application/atom+xml;type=entry" rel="self" href="http://127.0.0.1:8580/directory/shows/My%20Show.show" />
<viz:empty>false</viz:empty>
</entry>
</feed>
Updated Query:
var exEl = xmlDoc.XPathSelectElements("//atom:feed/atom:entry[atom:category/#term='show']", nameSpaceManager_);
foreach (var showNode in exEl.Cast<XElement>())
{
var showName = showNode.XPathSelectElement("/atom:entry/atom:title", nameSpaceManager_).Value;
var linkTypes = showNode.XPathSelectElements("/atom:entry/atom:link[#rel='alternate']", nameSpaceManager_)
.Select(e => e.Attribute("type").Value);
}
You do almost everything right.
Just use XPathSelectElement instead of XPathEvaluate.
var showName = showNode.XPathSelectElement("/atom:entry/atom:title", nameSpaceManager_).Value;
var linkTypes = showNode.XPathSelectElements("/atom:entry/atom:link[#rel='alternate']", nameSpaceManager_)
.Select(e => e.Attribute("type").Value);

Sum same named xml nodes

I have edited this little MSDN example https://support.microsoft.com/en-us/kb/311530
And I have the following 2 XML's
Book1.xml
<?xml version="1.0"?>
<catalog>
<book1 id="1" />
<bookSum number="1" />
</catalog>
Book2.xml
<?xml version="1.0"?>
<catalog>
<book2 id="2" />
<bookSum number="1" specialAttribute="123" />
</catalog>
C# Code
XmlReader xmlreader1 = XmlReader.Create(#"C:\Book1.xml");
XmlReader xmlreader2 = XmlReader.Create(#"C:\book2.xml");
DataSet ds = new DataSet();
ds.ReadXml(xmlreader1);
DataSet ds2 = new DataSet();
ds2.ReadXml(xmlreader2);
ds.Merge(ds2);
ds.WriteXml(#"C:\Merge.xml");
Console.WriteLine("Completed merging XML documents");
Merge.xml (Book1.xml + Book2.xml)
<?xml version="1.0" standalone="yes"?>
<catalog>
<book1 id="1" />
<bookSum number="1" />
<bookSum number="1" specialAttribute="x" />
<book2 id="2" />
</catalog>
And the question is
how to join
<bookSum number="1" />
<bookSum number="1" specialAttribute="123" />
into one line ?
<bookSum number="2" specialAttribute="123" />
I did it this way and is working:
var doc = XDocument.Load(#"C:\Book1.xml");
doc.Root.Add(XDocument.Load(#"C:\Book2.xml").Root.Elements()); // merged
var sum = doc.Descendants("bookSum").Attributes("number").Sum(t => int.Parse(t.Value));
var xElement = new XElement("bookSum", new XAttribute("number", sum));
foreach(var attrib in doc.Descendants("bookSum").Attributes())
{
if (xElement.Attribute(attrib.Name) == null)
xElement.Add(attrib);
}
doc.Descendants("bookSum").ToList().ForEach(t => t.ReplaceWith(xElement));
doc.Root.Descendants("bookSum").First().Remove();
Console.WriteLine(doc);

C# returning an XML element with ancestors and self, but no other children

I have an xml doc layout like so
<?xml version="1.0" encoding="utf-8" ?>
<Document name="document name">
<DataSet name="dataset 1">
<Dimension name="dimension 1">
<Metric name="metric 1">
<Data value="1">
<Data value="2">
<Data value="3">
</Metric>
<Metric name="metric 2">
<Data value="4">
<Data value="5">
<Data value="6">
</Metric>
</Dimension>
<Dimension name="dimension 2">
<Metric name="metric 3">
<Data value="6">
<Data value="7">
<Data value="8">
</Metric>
<Metric name="metric 4">
<Data value="9">
<Data value="10">
<Data value="11">
</Metric>
</Dimension>
</DataSet>
</Document>
I am attempting to split the Metrics out with their ancestors but not with their siblings. For example I want a file to look like...
<?xml version="1.0" encoding="utf-8" ?>
<Document name="document name">
<DataSet name="dataset 1">
<Dimension name="dimension 1">
<Metric name="metric 1">
<Data value="1">
<Data value="2">
<Data value="3">
</Metric>
</Dimension>
</DataSet>
</Document>
and file 2 to look like ...
<?xml version="1.0" encoding="utf-8" ?>
<Document name="document name">
<DataSet name="dataset 1">
<Dimension name="dimension 1">
<Metric name="metric 2">
<Data value="4">
<Data value="5">
<Data value="6">
</Metric>
</Dimension>
</DataSet>
</Document>
My attempt to solve this was to create a method that would accept an xmlfile, outputDirectory, elementName, attributeName, and attributeValue.
This would allow me to search the document for a specific metric and pull it out into its own file with its entire tree, but not with it's siblings.
at the top of my method i have...
XDocument doc = XDocument.Load(xmlFile);
IEnumerable<XElement> elementsInPath = doc.Descendants()
.Elements(elementName)
.Where(p => p.Attribute(attributeName).Value.Contains(attributeValue))
.AncestorsAndSelf()
.InDocumentOrder()
.ToList();
However when I iterate through the elementsInPath The output gives all of the parents of the matched "Metric" with each parent return all of its children, and the only child i want present is the one that was matched by the input params.
Any help would be appreciated. Just for reference I save the files using the following snippet
int i = 1;
foreach (XElement element in elementsInPath)
{
XDocument tmpDoc = new XDocument();
tmpDoc.Add(element);
tmpDoc.Save(outputDirectory + elementName + "_" + i + ".xml");
i++;
}
Also to note, If I use the following code I get the exact metrics I am looking for, but i need to encapsulate them within their parents.
IEnumerable<XElement> elementsInPath = doc.Descendants(elementName)
.Where(p => p.Attribute(attributeName).Value.Contains(attributeValue))
.InDocumentOrder()
.ToList();
So you're really building a new document for each Metric element. The most straightforward way to do this would be:
foreach (XElement el in doc.Root.Descendants("Metric"))
{
XElement newDoc =
new XElement("Document",
new XAttribute(doc.Root.Attribute("name")),
new XElement("DataSet",
new XAttribute(el.Parent.Parent.Attribute("name")),
new XElement("Dimension",
new XAttribute(el.Parent.Attribute("name")),
el)
)
)
);
newDoc.Save(el.Attribute("name").Value.Replace(" ", "_") + ".xml");
}
This hopefully illustrates how the dynamic version of this would work - iterate through the ancestors and create new elements based on them:
foreach (XElement el in doc.Root.Descendants("Metric"))
{
XElement newDoc = el;
foreach(XElement nextParent in el.Ancestors()) // iterate through ancestors
{
//rewrap in ancestor node name/attributes
newDoc = new XElement(nextParent.Name, nextParent.Attributes(), newDoc);
}
newDoc.Save(el.Attribute("name").Value.Replace(" ", "_") + ".xml");
}
Just using the Ancestors() functionality won't work, because when you tried to add them it would also add their children (the siblings of the element you're trying to split on).

Parsing XML Element

i am trying to parse an xml element (DItem >> Title)
below is my code but somehow i am not getting hold of it.... any help?
XDocument xdoc1 = XDocument.Load(url);
XNamespace ns = "http://sitename/items.xsd";
string topic = xdoc1.Descendants(ns + "DItem")
.Select(x => (string)x.Attribute("Title"))
.FirstOrDefault();
<?xml version='1.0'?>
<root xmlns="http://www.w3.org/2005/Atom">
<title type="text">title</title>
<entry>
<id>da7d3189-fd89-4d3f-901c-30eab7a3baa5</id>
<title type="text">Swimming Pools</title>
<summary type="text"></summary>
<updated>2011-08-19T19:02:21Z</updated>
<link rel="alternate" href="link" />
<link href="link" />
<content type="application/xml">
<Items xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.namespace.xsd">
<CatalogSource Acronym="ABC" OrganizationName="organization name" />
<Item Id="28466" CatalogUrl="url">
<DItem xmlns:content="http://namespace.xsd" TargetUrl="http://index.html" Title="my title">
<content:Source Acronym="ABC" OrganizationName="ABC" />
</DItem>
</Item>
</Items>
</content>
</entry>
</root>
Using the namespace "http://www.namespace.xsd" should (and does) work:
XNamespace ns = "http://www.namespace.xsd";
string topic = xdoc1.Descendants(ns + "DItem")
.Select(x => (string)x.Attribute("Title"))
.FirstOrDefault();
Since DItem is not qualified with a namespace itself, it will use the default namespace specified asxmlns="http://www.namespace.xsd" on its parent element.

Categories

Resources