COM MX Session Instance to XML?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • melissajean
    New Member
    • Aug 2010
    • 6

    COM MX Session Instance to XML?

    I am trying to connect to create an MX session using win32com tool and a file already written to create an MXSession. I want to be able to load a document off the server, and then manipulate it as if it were an XML document.

    Everything goes through successfully when I enter the code, but it returns a COMObject MSXML.DOMDocume nt, and will not allow me to alter it as if it was an XML Doc (I assume because it's actually a COM Object instance?). Does anyone know what I can use to be able to get as an XML instance? (Please be specific, this is my second week using Python!)

    Code:
    from mx import MXSession
    mx = MXSession("tmsuat")
    myDoc = mx.loadDoc("official/system.config/global/tcwrules/ecnsalesdata")
    <COMObject MSXML.DOMDocument>
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    Did you check the objects for methods and attributes?
    Code:
    dir(myDoc)

    Comment

    • melissajean
      New Member
      • Aug 2010
      • 6

      #3
      I changed the bounding on the COM Object after reading about it, using the make_py function. It now looks like:

      Code:
      doc
      <win32com.gen_py.Microsoft XML, v2.6.IXMLDOMDocument2 instance at 0x13855200>
      when I do the dir on my new doc file, I get:

      Code:
      ['CLSID', '_ApplyTypes_', '__cmp__', '__doc__', '__getattr__', '__init__', '__module__', '__repr__', '__setattr__', '_get_goo
      d_object_', '_get_good_single_object_', '_oleobj_', '_prop_map_get_', '_prop_map_put_', 'abort', 'appendChild', 'cloneNode',
      'coclass_clsid', 'createAttribute', 'createCDATASection', 'createComment', 'createDocumentFragment', 'createElement', 'create
      EntityReference', 'createNode', 'createProcessingInstruction', 'createTextNode', 'getElementsByTagName', 'getProperty', 'hasC
      hildNodes', 'insertBefore', 'load', 'loadXML', 'nodeFromID', 'removeChild', 'replaceChild', 'save', 'selectNodes', 'selectSin
      gleNode', 'setProperty', 'transformNode', 'transformNodeToObject', 'validate']
      I've checked out each of these options, but still cannot find a way to take out the string in the document. When using the getnodes, it returns "None" as having no nodes.

      Comment

      • bvdet
        Recognized Expert Specialist
        • Oct 2006
        • 2851

        #4
        Is the file a valid XML document? I know little about win32com, and I understand even less. I have some experience with XML and xml.dom.minidom , but that may not help you.

        Comment

        • melissajean
          New Member
          • Aug 2010
          • 6

          #5
          xml.dom.minidom and other xml manipulation tools won't work on it by itself right now. it throws the error "document has no read method".

          I am trying to load the document into a variable or something that would allow me to put those tools to use, but so far it's not working.

          I am able to save it to the harddrive using the save() function, but unfortunately the data I am using would take months to save to a harddrive so I'm trying to do it another way.

          Any help is appreciated!

          Comment

          Working...