XML to array VB.net


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: XML to array VB.net

  1. #1
    Join Date
    Dec 2009
    Posts
    8

    XML to array VB.net

    Is there a simple way to put xml data to an array. Other than making your own xml parser

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Feed your data into the XmlReader
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  3. #3
    Join Date
    Dec 2009
    Posts
    8

    problem

    This is my xml what it looks like

    Code:
    <?xml version="1.0" encoding="utf-8" standalone="yes"?><service_requests_table><service_requests><SR-Number>101</SR-Number><DSP-Number>101</DSP-Number><DSP-Date>101</DSP-Date><DSP-Status>101</DSP-Status><Service-Type>101</Service-Type><Callback>101</Callback><First-Name>101</First-Name><Last-Name>101</Last-Name><Email>101</Email><Phone-1>101</Phone-1><Phone-2>101</Phone-2><SR-Age>101</SR-Age><Note>101</Note></service_requests></service_requests_table>
    When i use xmlreader to pars into array it takes all parts of the xml
    I only want it to take for ex: <SR-Number>101</SR-Number> and read back 101. and there are empty lines in my array as well. How can i just make it read all the data fields values with out the xml version and the extra stuff i dont need

  4. #4
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    What programming language are you using? Here's an example in C#:
    Code:
    using System;
    using System.Collections;
    using System.Xml;
    
    string fileName = @"d:\path\filename.xml";
    ArrayList list = new ArrayList();
    
    using (XmlTextReader reader = new XmlTextReader(fileName))
    {
        while (reader.Read())
        {
            if (reader.NodeType == XmlNodeType.Text)
            {
                list.Add(reader.Value);
            }
        }
    }
    
    // Convert ArrayList to string array
    string[] values = list.ToArray(typeof(String)) as string[];
    Last edited by Phil Weber; 12-24-2009 at 05:01 PM.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

Similar Threads

  1. Question vb.net serialize object to xml properly
    By oleg.bourymenko in forum .NET
    Replies: 2
    Last Post: 01-15-2009, 01:23 PM
  2. VB.NET Array Help
    By shahan in forum .NET
    Replies: 0
    Last Post: 11-16-2006, 02:35 AM
  3. Replies: 0
    Last Post: 08-15-2002, 09:05 AM
  4. Poll: What are the best protocols to use with XML?
    By Randy Charles Morin in forum XML
    Replies: 5
    Last Post: 07-19-2002, 04:21 AM
  5. Check out Turbo XML: Free trial download
    By Extensibility in forum web.announcements
    Replies: 0
    Last Post: 07-20-2000, 06:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center