By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,254 Members | 1,310 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,254 IT Pros & Developers. It's quick & easy.

xml problem in .net

P: n/a
Hi all,
In my code, I need all "datasetMPI" nodes in an array. Here is a portion
of my xml file:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?mso-application progid="Word.Document"?>
<w:wordDocument
xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:w10="urn:schemas-microsoft-com:office:word"
xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core"
xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:ns0="http://tempuri.org/datasetMPI.xsd" w:macrosPresent="no"
w:embeddedObjPresent="no" w:ocxPresent="no" xml:space="preserve">
<w:body>
<wx:sect>
<ns0:datasetMPI>
<ns0:User><w:p>
<w:pPr>
<w:rPr>
<w:b/>
</w:rPr>
</w:pPr>
<ns0:Contact><w:r>
<w:rPr>
<w:b/>
</w:rPr>
<w:t>[Sender Name]</w:t>
</w:r></ns0:Contact>
</w:p>
<w:p>
<w:pPr>
<w:rPr>
<w:b/>
</w:rPr>
</w:pPr>
<ns0:Address1><w:r>
<w:rPr>
<w:b/>
</w:rPr>
<w:t>[Street Address]</w:t>
</w:r></ns0:Address1>
</w:p>
........

Now when I use the following code, the nodeListDataset list has 0 member.
As you can see above, it should contain at least one datasetMPI mode. What
am I doing wrong?
Thanks in advance.
XmlNode nodeBodySectionTemplate = null;

XmlDocument oXmlDocSectionTemplate = new XmlDocument();

XmlNamespaceManager nsm = new
XmlNamespaceManager(oXmlDocSectionTemplate.NameTab le);

nsm.AddNamespace( "ns0", @"http://tempuri.org/datasetMPI.xsd");

nsm.AddNamespace( "w",
@"http://schemas.microsoft.com/office/word/2003/wordml");
oXmlDocSectionTemplate.Load(sSectionTemplateFilePa th); //
sSectionTemplateFilePath points to my xml file.

if (oXmlDocSectionTemplate != null)

{

nodeBodySectionTemplate =
oXmlDocSectionTemplate.SelectSingleNode("//w:body",oNSMgr);

if (nodeBodySectionTemplate != null)

{

if (datasetMpiProposal != null)

{

XmlNodeList nodeListDataset = nodeBodySectionTemplate.SelectNodes("//ns0:" +
datasetMpiProposal.DataSetName,oNSMgr);

Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
I, unfortunately, do not have time right this second to dissect, but the most
common issue in XML is makign sure you are starting a search from the correct
node. I would check that first, as the point you start looking can greatly
alter your results.
---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************

"helpful sql" wrote:
Hi all,
In my code, I need all "datasetMPI" nodes in an array. Here is a portion
of my xml file:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?mso-application progid="Word.Document"?>
<w:wordDocument
xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:w10="urn:schemas-microsoft-com:office:word"
xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core"
xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:ns0="http://tempuri.org/datasetMPI.xsd" w:macrosPresent="no"
w:embeddedObjPresent="no" w:ocxPresent="no" xml:space="preserve">
<w:body>
<wx:sect>
<ns0:datasetMPI>
<ns0:User><w:p>
<w:pPr>
<w:rPr>
<w:b/>
</w:rPr>
</w:pPr>
<ns0:Contact><w:r>
<w:rPr>
<w:b/>
</w:rPr>
<w:t>[Sender Name]</w:t>
</w:r></ns0:Contact>
</w:p>
<w:p>
<w:pPr>
<w:rPr>
<w:b/>
</w:rPr>
</w:pPr>
<ns0:Address1><w:r>
<w:rPr>
<w:b/>
</w:rPr>
<w:t>[Street Address]</w:t>
</w:r></ns0:Address1>
</w:p>
........

Now when I use the following code, the nodeListDataset list has 0 member.
As you can see above, it should contain at least one datasetMPI mode. What
am I doing wrong?
Thanks in advance.
XmlNode nodeBodySectionTemplate = null;

XmlDocument oXmlDocSectionTemplate = new XmlDocument();

XmlNamespaceManager nsm = new
XmlNamespaceManager(oXmlDocSectionTemplate.NameTab le);

nsm.AddNamespace( "ns0", @"http://tempuri.org/datasetMPI.xsd");

nsm.AddNamespace( "w",
@"http://schemas.microsoft.com/office/word/2003/wordml");
oXmlDocSectionTemplate.Load(sSectionTemplateFilePa th); //
sSectionTemplateFilePath points to my xml file.

if (oXmlDocSectionTemplate != null)

{

nodeBodySectionTemplate =
oXmlDocSectionTemplate.SelectSingleNode("//w:body",oNSMgr);

if (nodeBodySectionTemplate != null)

{

if (datasetMpiProposal != null)

{

XmlNodeList nodeListDataset = nodeBodySectionTemplate.SelectNodes("//ns0:" +
datasetMpiProposal.DataSetName,oNSMgr);

Nov 21 '05 #2

P: n/a
Thanks. I search using "//" before a node's name, so should it matter where
i start searching?

"Cowboy (Gregory A. Beamer) - MVP" <No************@comcast.netNoSpamM> wrote
in message news:FB**********************************@microsof t.com...
I, unfortunately, do not have time right this second to dissect, but the
most
common issue in XML is makign sure you are starting a search from the
correct
node. I would check that first, as the point you start looking can greatly
alter your results.
---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************

"helpful sql" wrote:
Hi all,
In my code, I need all "datasetMPI" nodes in an array. Here is a
portion
of my xml file:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?mso-application progid="Word.Document"?>
<w:wordDocument
xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:w10="urn:schemas-microsoft-com:office:word"
xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core"
xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:ns0="http://tempuri.org/datasetMPI.xsd" w:macrosPresent="no"
w:embeddedObjPresent="no" w:ocxPresent="no" xml:space="preserve">
<w:body>
<wx:sect>
<ns0:datasetMPI>
<ns0:User><w:p>
<w:pPr>
<w:rPr>
<w:b/>
</w:rPr>
</w:pPr>
<ns0:Contact><w:r>
<w:rPr>
<w:b/>
</w:rPr>
<w:t>[Sender Name]</w:t>
</w:r></ns0:Contact>
</w:p>
<w:p>
<w:pPr>
<w:rPr>
<w:b/>
</w:rPr>
</w:pPr>
<ns0:Address1><w:r>
<w:rPr>
<w:b/>
</w:rPr>
<w:t>[Street Address]</w:t>
</w:r></ns0:Address1>
</w:p>
........

Now when I use the following code, the nodeListDataset list has 0
member.
As you can see above, it should contain at least one datasetMPI mode.
What
am I doing wrong?
Thanks in advance.
XmlNode nodeBodySectionTemplate = null;

XmlDocument oXmlDocSectionTemplate = new XmlDocument();

XmlNamespaceManager nsm = new
XmlNamespaceManager(oXmlDocSectionTemplate.NameTab le);

nsm.AddNamespace( "ns0", @"http://tempuri.org/datasetMPI.xsd");

nsm.AddNamespace( "w",
@"http://schemas.microsoft.com/office/word/2003/wordml");
oXmlDocSectionTemplate.Load(sSectionTemplateFilePa th); //
sSectionTemplateFilePath points to my xml file.

if (oXmlDocSectionTemplate != null)

{

nodeBodySectionTemplate =
oXmlDocSectionTemplate.SelectSingleNode("//w:body",oNSMgr);

if (nodeBodySectionTemplate != null)

{

if (datasetMpiProposal != null)

{

XmlNodeList nodeListDataset =
nodeBodySectionTemplate.SelectNodes("//ns0:" +
datasetMpiProposal.DataSetName,oNSMgr);

Nov 21 '05 #3

P: n/a
This all very poorly formed XML. I plugged it into XML spy and there are a
buch of problems with it syntactically.
Post well-formed XML here is you want additional help.

-Mark

"helpful sql" <no****@stopspam.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Thanks. I search using "//" before a node's name, so should it matter where i start searching?

"Cowboy (Gregory A. Beamer) - MVP" <No************@comcast.netNoSpamM> wrote in message news:FB**********************************@microsof t.com...
I, unfortunately, do not have time right this second to dissect, but the
most
common issue in XML is makign sure you are starting a search from the
correct
node. I would check that first, as the point you start looking can greatly alter your results.
---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************

"helpful sql" wrote:
Hi all,
In my code, I need all "datasetMPI" nodes in an array. Here is a
portion
of my xml file:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?mso-application progid="Word.Document"?>
<w:wordDocument
xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:w10="urn:schemas-microsoft-com:office:word"
xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core"
xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:ns0="http://tempuri.org/datasetMPI.xsd" w:macrosPresent="no"
w:embeddedObjPresent="no" w:ocxPresent="no" xml:space="preserve">
<w:body>
<wx:sect>
<ns0:datasetMPI>
<ns0:User><w:p>
<w:pPr>
<w:rPr>
<w:b/>
</w:rPr>
</w:pPr>
<ns0:Contact><w:r>
<w:rPr>
<w:b/>
</w:rPr>
<w:t>[Sender Name]</w:t>
</w:r></ns0:Contact>
</w:p>
<w:p>
<w:pPr>
<w:rPr>
<w:b/>
</w:rPr>
</w:pPr>
<ns0:Address1><w:r>
<w:rPr>
<w:b/>
</w:rPr>
<w:t>[Street Address]</w:t>
</w:r></ns0:Address1>
</w:p>
........

Now when I use the following code, the nodeListDataset list has 0
member.
As you can see above, it should contain at least one datasetMPI mode.
What
am I doing wrong?
Thanks in advance.
XmlNode nodeBodySectionTemplate = null;

XmlDocument oXmlDocSectionTemplate = new XmlDocument();

XmlNamespaceManager nsm = new
XmlNamespaceManager(oXmlDocSectionTemplate.NameTab le);

nsm.AddNamespace( "ns0", @"http://tempuri.org/datasetMPI.xsd");

nsm.AddNamespace( "w",
@"http://schemas.microsoft.com/office/word/2003/wordml");
oXmlDocSectionTemplate.Load(sSectionTemplateFilePa th); //
sSectionTemplateFilePath points to my xml file.

if (oXmlDocSectionTemplate != null)

{

nodeBodySectionTemplate =
oXmlDocSectionTemplate.SelectSingleNode("//w:body",oNSMgr);

if (nodeBodySectionTemplate != null)

{

if (datasetMpiProposal != null)

{

XmlNodeList nodeListDataset =
nodeBodySectionTemplate.SelectNodes("//ns0:" +
datasetMpiProposal.DataSetName,oNSMgr);


Nov 21 '05 #4

P: n/a
"Mark Rance" <no****@spamfree.com> wrote in message
news:St********************@pcisys.net...
This all very poorly formed XML.


Yep - it's not good...
Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.