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

Handling namespaces in XML...

P: 2
I think I understand using XMLnamespacemanager but I don't have a handle on what I'm doing wrong.

Here is a XML snippet.
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> 
  2. - <NewDataSet xmlns="http://www.inc.com.sc/MF_File">
  3. - <MF_File xmlns="http://www.inc.com.sc/MF_File" version="1.0">
  4.   <MFFileID>File12345</MFFileID> 
  5.   <FileType>MF</FileType> 
  6.   <FileDateTime>2012-07-19T16:58:18.210-04:00</FileDateTime> 
  7.   <JobControlNumber>ABVDREG_12</JobControlNumber> 
  8.   <TotalPackages>1</TotalPackages> 
  9.   <PrintCompleteDateTime>2012-07-19T17:58:18.210-04:00</PrintCompleteDateTime> 
  10.   <InsertCompleteDateTime>2012-07-19T18:58:18.210-04:00</InsertCompleteDateTime> 
  11.   <SortCompleteDateTime>2012-07-19T19:00:18.210-04:00</SortCompleteDateTime> 
  12. - <Batch>
  13.   <PrintFileName>PrintFile1</PrintFileName> 
  14. - <Package>
  15.   <CustomerPackageKey>00000000000002</CustomerPackageKey> 
  16.   <IncepturePackageKey>ABCD100X000001Q</IncepturePackageKey> 
  17.   <DispositionId>5</DispositionId> 
  18.   <DispositionDescription>Insert Successful</DispositionDescription> 
  19.   </Package>
Here is my code:
Expand|Select|Wrap|Line Numbers
  1. Dim mf_xmld As New XmlDocument()
  2. Dim mf_nodelist As XmlNodeList
  3. Dim mf_node As XmlNode = mf_xmld.DocumentElement
  4.  
  5. 'Create the XML Document
  6. mf_xmld = New XmlDocument()
  7.  
  8. 'Load the Xml file
  9.  mf_xmld.Load("C:\testxml.xml")
  10. Dim xmlnsManager As New XmlNamespaceManager(mf_xmld.NameTable)
  11. xmlnsManager.AddNamespace("nds", "http://www.inc.com.sc/MF_File")
  12.  
  13. 'Get the list of name nodes 
  14. mf_nodelist = mf_xmld.SelectNodes("nds:NewDataSet/nds:MF_FIle/nds:Batch/nds:Package", xmlnsManager)
  15. 'mf_nodelist = mf_xmld.ChildNodes
  16. 'Loop through the nodes
  17. For Each mf_node In mf_nodelist
  18.   Dim customerpackagekeyvalue = mf_node.ChildNodes.Item(0).InnerText
  19.   Dim incepturepackagekeyvalue = mf_node.ChildNodes.Item(1).InnerText
  20.   Dim dispositionIdvalue = mf_node.ChildNodes.Item(2).InnerText
  21.   Dim DispositionDescriptionvalue = mf_node.ChildNodes.Item(3).InnerText
  22.  
I am very new to XML so forgive any obvious flaws and thanks in advance for your help.

Christmas
Aug 2 '12 #1
Share this Question
Share on Google+
1 Reply


P: 2
I have this figured out.
Aug 3 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.