BiT wrote:
i tried to play with it and understand how this namespace work, but i
didn't =>
can u explain little on this namespace and for example how can i retrive
the segment size or the file name
If you have an XML document starting like this:
<nzb xmlns="http://www.newzbin.com/DTD/2003/nzb">
<file subject="Linux Debian-3.1r5-i386-binary- CD1 Lucky Strike.par2
(1/1)"
date="1175058765" poster="Ye**@power-post.org (Lucky Strike)">
<groups>
<group>alt.binaries.cd.image.linux</group>
</groups>
<segments>
<segment bytes="423495"
number="1">b5**************************@news.usene xt.de</segment>
then the root element nzb has a default namespace declaration
xmlns="http://www.newzbin.com/DTD/2003/nzb"
which applies to the root element and all its descendant elements
(unless a descendant had it own redeclaration of xmlns).
So this means that the nzb element and its descendant elements like
file, groups, group, segments, segment are in the namespace with name
http://www.newzbin.com/DTD/2003/nzb.
For XPath 1.0 to match such elements you need to bind a prefix to the
namespace URI and use that prefix in XPath expressions. That is
necessary as in an XPath expression
nzb
always matches nzb elements in _no_ namespace.
As for accessing a segment size in bytes, that is an attribute of the
element you can access like this:
For Each segment As XmlElement In
xmlDoc.SelectNodes("/pf:nzb/pf:file/pf:segments/pf:segment",
namespaceManager)
Console.WriteLine(segment.Attributes("bytes").Valu e)
Next
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/