xml problem in .net

H

helpful sql

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:blush:ffice: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:blush:="urn:schemas-microsoft-com:blush:ffice:blush:ffice"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:ns0="http://tempuri.org/datasetMPI.xsd" w:macrosPresent="no"
w:embeddedObjPresent="no" w:blush:cxPresent="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.NameTable);

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

nsm.AddNamespace( "w",
@"http://schemas.microsoft.com/office/word/2003/wordml");


oXmlDocSectionTemplate.Load(sSectionTemplateFilePath); //
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);
 
G

Guest

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!
***************************
 
H

helpful sql

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

Cowboy (Gregory A. Beamer) - MVP said:
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 said:
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:blush:ffice: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:blush:="urn:schemas-microsoft-com:blush:ffice:blush:ffice"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:ns0="http://tempuri.org/datasetMPI.xsd" w:macrosPresent="no"
w:embeddedObjPresent="no" w:blush:cxPresent="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.NameTable);

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

nsm.AddNamespace( "w",
@"http://schemas.microsoft.com/office/word/2003/wordml");


oXmlDocSectionTemplate.Load(sSectionTemplateFilePath); //
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);
 
M

Mark Rance

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 said:
Thanks. I search using "//" before a node's name, so should it matter where
i start searching?

in message news:[email protected]...
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 said:
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:blush:ffice: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:blush:="urn:schemas-microsoft-com:blush:ffice:blush:ffice"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:ns0="http://tempuri.org/datasetMPI.xsd" w:macrosPresent="no"
w:embeddedObjPresent="no" w:blush:cxPresent="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.NameTable);

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

nsm.AddNamespace( "w",
@"http://schemas.microsoft.com/office/word/2003/wordml");


oXmlDocSectionTemplate.Load(sSectionTemplateFilePath); //
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);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top