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. C / C++ / MFC
  4. how can i handle file commands to read and write xml files

how can i handle file commands to read and write xml files

Scheduled Pinned Locked Moved C / C++ / MFC
comxmlarchitecturequestion
4 Posts 2 Posters 0 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.
  • P Offline
    P Offline
    pathi
    wrote on last edited by
    #1

    Hi I serialized my data in an xml file but how can I open or save them using Document view architecture.I want to read data from document and use it in view. I will be glad if I get a clear answer. Thanks Pathi Gorantla bhikshapathi_g@semanticspace.com

    T 1 Reply Last reply
    0
    • P pathi

      Hi I serialized my data in an xml file but how can I open or save them using Document view architecture.I want to read data from document and use it in view. I will be glad if I get a clear answer. Thanks Pathi Gorantla bhikshapathi_g@semanticspace.com

      T Offline
      T Offline
      Tomasz Sowinski
      wrote on last edited by
      #2

      You have to override CDocument::OnOpenDocument and CDocument::OnSaveDocument. Do not call base class implementaion - just open your own file and read/write. Tomasz Sowinski -- http://www.shooltz.com.pl

      P 1 Reply Last reply
      0
      • T Tomasz Sowinski

        You have to override CDocument::OnOpenDocument and CDocument::OnSaveDocument. Do not call base class implementaion - just open your own file and read/write. Tomasz Sowinski -- http://www.shooltz.com.pl

        P Offline
        P Offline
        pathi
        wrote on last edited by
        #3

        Yeah I am trying to override OnOpenDocument() but i cant get the data from file into the document.I declared DISPPARAMS pointer in document and trying to get the data read from file into this pointer but getting an error.my aim is to read from file and show it in view. my code is void componentView::fileOpen() { isFileOpen=true; CFileDialog file(true, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, NULL, GetParent()); file.DoModal(); CString filep=file.GetPathName(); BSTR filepath; TCHAR szStringRepresentation[200]; wsprintf ( szStringRepresentation, _T("%s"), filep ); filepath=_bstr_t(szStringRepresentation) ; CClientDC cdc(this); CPen penStroke(PS_SOLID, 1, RGB(0,0,0)); cdc.SelectObject(&penStroke); parse pa; DISPPARAMS var=pa.readFile(filepath); DISPPARAMS *params; params=&var; VARIANT myVars[2]; VariantInit(&myVars [0]); myVars[0].vt=VT_ARRAY|VT_I4; myVars[0]=params->rgvarg[0]; VariantInit(&myVars [1]); myVars[1].vt=VT_ARRAY|VT_I4; myVars[1]=params->rgvarg[1]; SAFEARRAY* SXArray; SAFEARRAY* SYArray; SXArray=myVars[0].parray; SYArray=myVars[1].parray; long lxbound,lybound; long uxbound,uybound; SafeArrayGetLBound(SXArray,1,&lxbound); SafeArrayGetUBound(SXArray,1,&uxbound); SafeArrayGetLBound(SYArray,1,&lybound); SafeArrayGetUBound(SYArray,1,&uybound); VARIANT ptVar; VariantInit(&ptVar); ptVar.vt=VT_BSTR; int i,j,k,l; for(long p=lxbound;p<=uxbound;p++) { SafeArrayGetElement(SXArray,&p,(&ptVar.bstrVal)); i=strtol(_bstr_t(ptVar.bstrVal),NULL,10); SafeArrayGetElement(SYArray,&p,(&ptVar.bstrVal)); k=strtol(_bstr_t(ptVar.bstrVal),NULL,10); p++; SafeArrayGetElement(SXArray,&p,(&ptVar.bstrVal)); j=strtol(_bstr_t(ptVar.bstrVal),NULL,10); SafeArrayGetElement(SYArray,&p,(&ptVar.bstrVal)); l=strtol(_bstr_t(ptVar.bstrVal),NULL,10); cdc.MoveTo(i,k); cdc.LineTo(j,l); } } I did in view but how can I read file in document and draw the lines in view? bhikshapathi_g@semanticspace.com

        T 1 Reply Last reply
        0
        • P pathi

          Yeah I am trying to override OnOpenDocument() but i cant get the data from file into the document.I declared DISPPARAMS pointer in document and trying to get the data read from file into this pointer but getting an error.my aim is to read from file and show it in view. my code is void componentView::fileOpen() { isFileOpen=true; CFileDialog file(true, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, NULL, GetParent()); file.DoModal(); CString filep=file.GetPathName(); BSTR filepath; TCHAR szStringRepresentation[200]; wsprintf ( szStringRepresentation, _T("%s"), filep ); filepath=_bstr_t(szStringRepresentation) ; CClientDC cdc(this); CPen penStroke(PS_SOLID, 1, RGB(0,0,0)); cdc.SelectObject(&penStroke); parse pa; DISPPARAMS var=pa.readFile(filepath); DISPPARAMS *params; params=&var; VARIANT myVars[2]; VariantInit(&myVars [0]); myVars[0].vt=VT_ARRAY|VT_I4; myVars[0]=params->rgvarg[0]; VariantInit(&myVars [1]); myVars[1].vt=VT_ARRAY|VT_I4; myVars[1]=params->rgvarg[1]; SAFEARRAY* SXArray; SAFEARRAY* SYArray; SXArray=myVars[0].parray; SYArray=myVars[1].parray; long lxbound,lybound; long uxbound,uybound; SafeArrayGetLBound(SXArray,1,&lxbound); SafeArrayGetUBound(SXArray,1,&uxbound); SafeArrayGetLBound(SYArray,1,&lybound); SafeArrayGetUBound(SYArray,1,&uybound); VARIANT ptVar; VariantInit(&ptVar); ptVar.vt=VT_BSTR; int i,j,k,l; for(long p=lxbound;p<=uxbound;p++) { SafeArrayGetElement(SXArray,&p,(&ptVar.bstrVal)); i=strtol(_bstr_t(ptVar.bstrVal),NULL,10); SafeArrayGetElement(SYArray,&p,(&ptVar.bstrVal)); k=strtol(_bstr_t(ptVar.bstrVal),NULL,10); p++; SafeArrayGetElement(SXArray,&p,(&ptVar.bstrVal)); j=strtol(_bstr_t(ptVar.bstrVal),NULL,10); SafeArrayGetElement(SYArray,&p,(&ptVar.bstrVal)); l=strtol(_bstr_t(ptVar.bstrVal),NULL,10); cdc.MoveTo(i,k); cdc.LineTo(j,l); } } I did in view but how can I read file in document and draw the lines in view? bhikshapathi_g@semanticspace.com

          T Offline
          T Offline
          Tomasz Sowinski
          wrote on last edited by
          #4

          > I did in view but how can I read file in document and > draw the lines in view? You should read the file in OnOpenDocument and store the data in your document class. Use this data in overrided OnDraw in view class and draw whatever you want. Tomasz Sowinski -- http://www.shooltz.com.pl

          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