Results 1 to 18 of 18

Thread: do you know xml ?

  1. #1

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    do you know xml ?

    Code:
    <report entireList="False">
    		<computer  computerName="jamie" computerOS="Windows 2000 (NT 5.0.2195)" reportCreated="6/8/02 13:05:35" userLoggedOn="jamie">
    			<computerHardware>
    				<cpu>
    				<cpuNumberOfCPUs>1</cpuNumberOfCPUs>
    				<cpuProcessorLevel>Intel Pentium Pro, II, III or 4</cpuProcessorLevel>
    				<cpuProcessorRevision>Model 8, Stepping 3</cpuProcessorRevision>
    				<cpuProcessorSpeed>646 MHz</cpuProcessorSpeed>
    				<cpuProcessorType>Pentium</cpuProcessorType>
    				</cpu>
    				<drives>
    					<drive>
    						<driveName>A:\</driveName>
    						<driveSort>Removable drive</driveSort>
    						<driveLabel>NoName</driveLabel>
    						<driveSerial>0000-0000</driveSerial>
    						<driveSize>0 Bytes</driveSize>
    						<driveFree>0 Bytes</driveFree>
    						<driveUsed>0 Bytes</driveUsed>
    						<driveType>Removable drive</driveType>
    					</drive>
    					<drive>
    						<driveName>C:\</driveName>
    						<driveSort>Fixed drive</driveSort>
    						<driveLabel>LOCAL DISK</driveLabel>
    						<driveSerial>137A-10F8</driveSerial>
    						<driveSize>12,054,659,072 Bytes</driveSize>
    						<driveFree>462,921,728 Bytes</driveFree>
    						<driveUsed>11,591,737,344 Bytes</driveUsed>
    						<driveType>Fixed drive</driveType>
    					</drive>
    					<drive>
    						<driveName>E:\</driveName>
    						<driveSort>CD-ROM drive</driveSort>
    						<driveLabel>NoName</driveLabel>
    						<driveSerial>0000-0000</driveSerial>
    						<driveSize>0 Bytes</driveSize>
    						<driveFree>0 Bytes</driveFree>
    						<driveUsed>0 Bytes</driveUsed>
    						<driveType>CD-ROM drive</driveType>
    					</drive>
    				</drives>
    				<memory>
    					<memoryFreeMemory>106,500 KBytes</memoryFreeMemory>
    					<memoryPercentUsed>59 %</memoryPercentUsed>
    					<memoryTotalMemory>261,552 KBytes</memoryTotalMemory>
    				</memory>
    				<printers>
    					<printerInfo>Fax</printerInfo>
    					<printerInfo>\\NTSERVER\HP LaserJet 5P/5MP (HP)</printerInfo>
    				</printers>
    			</computerHardware>
    			<installedApplications>
    				<DisplayName>              Adobe Acrobat 4.0, 5.0</DisplayName>
    				<DisplayVersion>5.0</DisplayVersion>
    				<InstallLocation>C:\Program Files\Adobe\Acrobat 5.0</InstallLocation>
    				<Publisher>Adobe Systems, Inc.</Publisher>
    				<UninstallString>C:\WINDOWS\ISUNINST.EXE -f"C:\Program Files\Common Files\Adobe\Acrobat 5.0\NT\Uninst.isu" -c"C:\Program Files\Common Files\Adobe\Acrobat 5.0\NT\Uninst.dll"</UninstallString>
    				<URLInfoAbout>http://www.adobe.com/prodindex/acrobat/main.html</URLInfoAbout>
    				<DisplayName>              AOL Instant Messenger (SM)</DisplayName>
    				<DisplayVersion></DisplayVersion>
    				<InstallLocation></InstallLocation>
    				<Publisher></Publisher>
    				<UninstallString>C:\Program Files\AIM95\uninstll.exe -LOG= C:\Program Files\AIM95\install.log -OEM=</UninstallString>
    				<URLInfoAbout></URLInfoAbout>
    
    etc. etc.
    Just wondering, If I'm recording, the computer name, OS, installed applications, some hardware info, how should it be laid out in an xml file ?
    I've ****all experience with XML...

    So I was thinking, the first part there <computer blah= ....>, originally that was :

    Code:
    <computer>
          <computerName>jamie</computerName> 
          <computerOS>Windows 2000 (NT 5.0.2195)</computerOS>
          <reportCreated>6/8/02 13:05:35</reportCreated> 
          <userLoggedOn>jamie</userLoggedOn>
    
           <computerHardware>
                <cpu>
                      ...
    But well... both look sorta correct.
    So I'm not sure which one to go with.
    And as there is loads of other information I have to record, just wondering what's the proper way ?
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  2. #2
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205

    Re: do you know xml ?

    Originally posted by plenderj
    [Bdo you know xml ?[/B]
    No.
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  3. #3

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    Re: Re: do you know xml ?

    Originally posted by rjlohan


    No.
    scruttox
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  4. #4
    Hyperactive Member
    Join Date
    Jun 2000
    Posts
    350
    Jamie,

    AFAIK both of those methods are 'proper' in the sense of being syntactically correct. I lean towards the

    Code:
    <computer>
        <name>jim</name>
       <os>Dos3</os>
    </computer>
    rather than the

    Code:
    <computer name="jim">
    ....
    approach.

    At least one XML ingestor that I know of, can't extract the data from inside the tag in the first place so one is forced to use the other method; that might just be an oversight though and could get fixed I guess.

    The way I've seen the data in the tag explained in tutorials it makes me think it's differentiating between similar types of data like a home- and office-phone, thusly...

    Code:
    <customer>
        <phone type="home">555-1234</phone>
        <phone type="work">555-9999</phone>
    </customer>
    It's a sort of meta-data rather than normal-data...
    Last edited by Jim Brown; Aug 19th, 2002 at 03:24 AM.
    .

  5. #5

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Hmmm thanks for the reply jim.
    I think I'll stick with enclosing things inside tags then, instead of putting things in as a parameter inside a tag, as in your first example.

    One problem I noticed though is that if the is the '&' character, it ****s things up, unless thats in as a parameter.
    But afaik, I can just use the CDATA thang for that
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  6. #6

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    And here's another way of doing it ...
    http://msdn.microsoft.com/library/de...ksxml_30rw.asp
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  7. #7
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    I think that the XML could stand a bit of normalisation...for example, number of CPUs is an attribute of Hardware, not of an individual CPU.

    e.g.
    Code:
    <computerHardware>
    <hardwareNumberOfCPUs>1</hardwareNumberOfCPUs>
      <cpu>
          <cpuProcessorLevel>Intel Pentium Pro, II, III or 4</cpuProcessorLevel>
           <cpuProcessorRevision>Model 8, Stepping 3</cpuProcessorRevision>
            <cpuProcessorSpeed>646 MHz</cpuProcessorSpeed>
            <cpuProcessorType>Pentium</cpuProcessorType>
          </cpu>
    Hope this helps,
    Duncan
    ----8<---------------------------------------
    NEW - The .NET printer queue monitor component
    ----8<---------------------------------------
    Now with Examples of use

  8. #8

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    So you don't think I should go with the whole approach of using data as parameters :

    <cpu number="1" cpuProcessorLevel="Intel Pentium Pro, II, III or 4" cpuProcessorRevision="Model 8, Stepping 3" ... />
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  9. #9
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    Actually - I do prefer that second method...
    ----8<---------------------------------------
    NEW - The .NET printer queue monitor component
    ----8<---------------------------------------
    Now with Examples of use

  10. #10

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Uhn. Back to square one.
    So how am I supposed to output the data.

    Put everything in inverted commas, or use tags or what.
    That microsoft example uses both.

    I suppose I can put everything about the computer in tags, but the computer tag itself I can put in a name= parameter, just like Microsoft does for the book ID
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  11. #11
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    dont you use SOAP for using xml inyour programs?
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  12. #12

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    No I'm doing it myself
    VB Code:
    1. Dim nodX As Node, nodY As Node, parents() As Node: ReDim parents(0)
    2.                         Open strFileName For Output As #3
    3.                             Print #3, "<?xml version=" & Chr(34) & "1.0" & Chr(34) & " ?>"
    4.                             Print #3, "<!--                                                                    -->"
    5.                             Print #3, "<!--                                                                    -->"
    6.                             Print #3, "<report entireList=" & Chr(34) & CStr((reportScope = EntireList)) & Chr(34) & ">"
    7.                            
    8.                                         For Each nodX In frmMain.TreeView1.Nodes
    9.                                             If Not InStr(nodX.Key, Chr(0)) = 0 Then
    10.                                                 Set parents(UBound(parents)) = nodX
    11.                                                 ReDim Preserve parents(UBound(parents) + 1)
    12.                                             End If
    13.                                         Next
    14.                                         For i = 0 To UBound(parents) - 1
    15.                                             Set nodY = parents(i).Child
    16.                                             Do
    17.                                                     hKey = CLng(Replace(nodY.Key, "_", ""))
    18.                                                     With systemReportInformation(hKey)
    19.                                                         Print #3, String(2, vbTab) & "<computer " & _
    20.                                                             " computerName=" & Chr(34) & .aReportOnComputer & Chr(34) & _
    21.                                                             " computerOS=" & Chr(34) & .bOperatingSystem & Chr(34) & _
    22.                                                             " reportCreated=" & Chr(34) & .cCreated & Chr(34) & _
    23.                                                             " userLoggedOn=" & Chr(34) & .dUserLoggedOnAs & Chr(34) & ">"
    24.  
    25.                                                         Print #3, String(3, vbTab) & "<computerHardware>"
    26.                                                             With .fHardWareInfo
    27.                                                                 Print #3, String(4, vbTab) & "<cpu>"
    28.                                                                     With .CPU
    29.                                                                         printXML 3, 4, "cpuNumberOfCPUs", .cpuNumberOfCPUs
    30.                                                                         printXML 3, 4, "cpuProcessorLevel", .cpuProcessorLevel
    31.                                                                         printXML 3, 4, "cpuProcessorRevision", .cpuProcessorRevision
    32.                                                                         printXML 3, 4, "cpuProcessorSpeed", .cpuProcessorSpeed
    33.                                                                         printXML 3, 4, "cpuProcessorType", .cpuProcessorType
    34.                                                                     End With
    35.                                                                 Print #3, String(4, vbTab) & "</cpu>"
    36.  
    37.  
    38. '' etc.
    39.  
    40.  
    41. '' and then
    42. Private Function printXML(ByVal lngFileNum As Long, ByVal lngIndent As Long, ByVal strName As String, ByVal strData As String)
    43.     Print #lngFileNum, String(lngIndent, vbTab) & "<" & strName & ">" & strData & "</" & strName & ">"
    44. End Function
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  13. #13
    Fanatic Member
    Join Date
    Apr 2000
    Location
    Whats a location?
    Posts
    516
    How about we forget our differences and make cheese muffins?
    Courgettes.

  14. #14
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    ah ok, i see

    what do you mean output the data? pullit from the xml file and show it? sinc eyou know what tags are there, itll be the same way you put it in i guess
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  15. #15

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    You see I've got my UDTs, and need to basically turn them into XML.

    But I'm unsure as to how fields are laid out in XML and whether things should always have their own tags or be put inside other tags or what...
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  16. #16

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    I think I may have figured this out.

    Take a look at the sample here, and also microsoft's sample.
    http://outer-court.com/tech/forum.htm


    From what I can see, you put things in as parameters inside the tag (eg. <computer name="jamie">), so as to identify the <computer> tag itself.

    And then everything else contained between the opening and closing <computer> tags goes in as just things between tags.
    Except for the InstalledSoftware part which should probablty look like :

    Code:
    <installedApplications>
    	<Application name="Adobe Acrobat 4.0, 5.0">
    		<DisplayVersion>5.0</DisplayVersion>
    		<InstallLocation>C:\Program Files\Adobe\Acrobat 5.0</InstallLocation>
    		<Publisher>Adobe Systems, Inc.</Publisher>
    		<UninstallString>C:\WINDOWS\ISUNINST.EXE -f"C:\Program Files\Common Files\Adobe\Acrobat 5.0\NT\Uninst.isu" -c"C:\Program Files\Common Files\Adobe\Acrobat 5.0\NT\Uninst.dll"</UninstallString>
    		<URLInfoAbout>http://www.adobe.com/prodindex/acrobat/main.html</URLInfoAbout>
    	</Application>
    	<Application name="AOL Instant Messenger (SM)">
    		<DisplayVersion></DisplayVersion>
    		<InstallLocation></InstallLocation>
    		<Publisher></Publisher>
    		<UninstallString>C:\Program Files\AIM95\uninstll.exe -LOG= C:\Program Files\AIM95\install.log -OEM=</UninstallString>
    		<URLInfoAbout></URLInfoAbout>
    	</Application>
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  17. #17
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    OK - so unique key goes in quotations, attributes get their own tags...

    like:
    Code:
    <vehicleClass make="Triumph" model="GT6">
        <vehicleInstance registration="OLJ 565 M">
            <claim claim_number= "AU000002">
                <claimLossType>Auto Own Damage</claimLossType>
                <claimAmount>
                     <currency>Euro</currency>
                     <amount>1500.00</amount>
                </claimAmount>
            </claim>
        </vehicleInstance>
    </vehicleClass>
    Does that sound about right?
    ----8<---------------------------------------
    NEW - The .NET printer queue monitor component
    ----8<---------------------------------------
    Now with Examples of use

  18. #18

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Yeah pretty much so what I was thinking.
    Even though all ways of doing it are syntatically correct, I think this makes the most sense
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width