Parsing XML

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sspost
    New Member
    • Sep 2007
    • 15

    Parsing XML

    I have an XML that looks like this

    <DataUser>
    <Create>
    <Element>Common </Element>
    <Display>Stat e Value</Display>
    </Create>
    </DataUser>

    how do i parse it?
    I used

    Dim str as string = xmlDocument.Sel ectSingleNode("//Create/Element", nsmanager).Inne rText

    but it gives "Object Refernce set to NULL " exception

    what should i do ?
  • Shashi Sadasivan
    Recognized Expert Top Contributor
    • Aug 2007
    • 1435

    #2
    have you initialized the xmlDocument object?

    Comment

    • sspost
      New Member
      • Sep 2007
      • 15

      #3
      [yes I did initialize it
      here's rest of the code
      <DataUser>
      <Create>
      <Element>Common </Element>
      <Display>Stat e Value</Display>
      </Create>
      </DataUser>

      Dim xmlDoc As New System.Xml.XmlD ocument
      xmlDoc.LoadXml( myXML)

      'Create a namespace manager

      Dim nsManager As XmlNamespaceMan ager
      nsManager = New XmlNamespaceMan ager(xmlDoc.Nam eTable)

      nsManager.AddNa mespace("……….")


      XmlNodeList = xmlDoc.SelectNo des("DataUser")


      Dim Display as string = xmlDoc.SelectSi ngleNode("Creat e/Display", nsManager).Inne rText

      what's wrong with the code? Anyone?

      Comment

      Working...