Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. What wrong with this clause??

What wrong with this clause??

Scheduled Pinned Locked Moved XML / XSL
xmlquestion
4 Posts 3 Posters 11 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tida
    wrote on last edited by
    #1

    Dear all, I try to select node from a XML file: but always failed: there are nodes in the file but the select result are no. What wrong with my code or the structure/name of my XML file? my code: -------------------------- MSXML::IXMLDOMDocumentPtr pDoc = NULL; MSXML::IXMLDOMElementPtr root; MSXML::IXMLDOMNodePtr userParent, userNode; MSXML::IXMLDOMNodeListPtr userList; root = pDoc->documentElement; userParent=root->selectSingleNode(_bstr_t("Users")); strServer="gmitc-data3"; strVolume="d:\Shared Volume"; temp=strServer+"\\"+strVolume; userList=userParent->selectNodes(_bstr_t\ ("User[@Class1Root='"+temp+"']")); for( int k=0; kGetlength(); k++) { m_nCount++; userNode=userList->Getitem(k); strUser=(LPCTSTR)_bstr_t(userNode->attributes\ ->getNamedItem(_bstr_t("Name"))->text); m_Grid.SetRows(m_nCount+1); m_Grid.SetTextArray(m_nCols*m_nCount+2,strUser); }// end for(userList) --------------------------- my xml file: --------------------------- " ---------------------------------

    C R 2 Replies Last reply
    0
    • T Tida

      Dear all, I try to select node from a XML file: but always failed: there are nodes in the file but the select result are no. What wrong with my code or the structure/name of my XML file? my code: -------------------------- MSXML::IXMLDOMDocumentPtr pDoc = NULL; MSXML::IXMLDOMElementPtr root; MSXML::IXMLDOMNodePtr userParent, userNode; MSXML::IXMLDOMNodeListPtr userList; root = pDoc->documentElement; userParent=root->selectSingleNode(_bstr_t("Users")); strServer="gmitc-data3"; strVolume="d:\Shared Volume"; temp=strServer+"\\"+strVolume; userList=userParent->selectNodes(_bstr_t\ ("User[@Class1Root='"+temp+"']")); for( int k=0; kGetlength(); k++) { m_nCount++; userNode=userList->Getitem(k); strUser=(LPCTSTR)_bstr_t(userNode->attributes\ ->getNamedItem(_bstr_t("Name"))->text); m_Grid.SetRows(m_nCount+1); m_Grid.SetTextArray(m_nCols*m_nCount+2,strUser); }// end for(userList) --------------------------- my xml file: --------------------------- " ---------------------------------

      C Offline
      C Offline
      Christopher Lord
      wrote on last edited by
      #2

      "User[@Class1Root='"+temp+"']" appears wrong at first glance, since all User tags are contained within the Users tag. thus, that xpath should read "Users/User[@Class1Root='"+temp+"']" Also, you may want to develop on your local drive, and not over a network share. This eleminates a source of errors in your code, which may also be the reason. * Edit: looking at your code (imagine that :)), I see you retrieve the User tag at an earlier step, and then run the above xpath on that node. Perhaps ensure it works from a local file instead of a network share.

      T 1 Reply Last reply
      0
      • C Christopher Lord

        "User[@Class1Root='"+temp+"']" appears wrong at first glance, since all User tags are contained within the Users tag. thus, that xpath should read "Users/User[@Class1Root='"+temp+"']" Also, you may want to develop on your local drive, and not over a network share. This eleminates a source of errors in your code, which may also be the reason. * Edit: looking at your code (imagine that :)), I see you retrieve the User tag at an earlier step, and then run the above xpath on that node. Perhaps ensure it works from a local file instead of a network share.

        T Offline
        T Offline
        Tida
        wrote on last edited by
        #3

        I got an idea from your opinion. Thanks a lot.:-D

        1 Reply Last reply
        0
        • T Tida

          Dear all, I try to select node from a XML file: but always failed: there are nodes in the file but the select result are no. What wrong with my code or the structure/name of my XML file? my code: -------------------------- MSXML::IXMLDOMDocumentPtr pDoc = NULL; MSXML::IXMLDOMElementPtr root; MSXML::IXMLDOMNodePtr userParent, userNode; MSXML::IXMLDOMNodeListPtr userList; root = pDoc->documentElement; userParent=root->selectSingleNode(_bstr_t("Users")); strServer="gmitc-data3"; strVolume="d:\Shared Volume"; temp=strServer+"\\"+strVolume; userList=userParent->selectNodes(_bstr_t\ ("User[@Class1Root='"+temp+"']")); for( int k=0; kGetlength(); k++) { m_nCount++; userNode=userList->Getitem(k); strUser=(LPCTSTR)_bstr_t(userNode->attributes\ ->getNamedItem(_bstr_t("Name"))->text); m_Grid.SetRows(m_nCount+1); m_Grid.SetTextArray(m_nCols*m_nCount+2,strUser); }// end for(userList) --------------------------- my xml file: --------------------------- " ---------------------------------

          R Offline
          R Offline
          Ranjan Banerji
          wrote on last edited by
          #4

          in line: strVolume="d:\Shared Volume"; you need to have strVolume="d:\\Shared Volume"; This will not show up as an error when u compile but as a warning about some escape characters. Always check warnings. Your code should not only be error free but also warning free. This could be another reason why your code did not work as your code will resolve to D:Share Volume while you are matching d:\shared......

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups