XML Parsing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jose Cintron

    #1

    XML Parsing

    The XML file looks something like this...

    --- Start XML ---
    <?xml version="1.0" ?>
    <VULNERABILITIE S>
    <PROGRAM_VERSIO N>0.0.1</PROGRAM_VERSION >
    <CONTROL_VERSIO N>0.0.1</CONTROL_VERSION >
    <VULNERABILIT Y>
    <V_SHORT_NAME>S OMETHING</V_SHORT_NAME>
    <V_LONG_NAME>SO METHING</V_LONG_NAME>
    <V_DISCUSSION>N ICE DESCRIPTION</V_DISCUSSION>
    <V_REFERENCE>
    <V_CATEGORY>SOM ETHING</V_CATEGORY>
    <ID>1</ID>
    </VULNERABILITY>
    <VULNERABILIT Y>
    <V_SHORT_NAME>S OMETHING</V_SHORT_NAME>
    <V_LONG_NAME>SO METHING</V_LONG_NAME>
    <V_DISCUSSION>N ICE DESCRIPTION</V_DISCUSSION>
    <V_REFERENCE>
    <V_CATEGORY>SOM ETHING</V_CATEGORY>
    <ID>2</ID>
    </VULNERABILITY>
  • Sean M. DonCarlos

    #2
    RE: XML Parsing

    "Jose Cintron" wrote:
    [color=blue]
    > ...
    > ..\XMLparse.cpp (16) : error C3622: 'System::Xml::X mlReader': a class declared
    > as 'abstract' cannot be instantiated[/color]

    Correct. You can't directly create XmlReader objects with gcnew.
    [color=blue]
    > ..\XMLparse.cpp (16) : error C3673: 'System::Xml::X mlReader' : class does not
    > have a copy-constructor[/color]

    Also correct, because XmlReader is abstract.
    [color=blue]
    > Just in case it makes a difference I'm using Visual C++ Express Edition.
    > Any ideas will be greatly appreciated[/color]

    See the System::Xml::Xm lReader.Create( ...) family of methods. You can create
    various kinds of XmlReaders there, depending on where your XML is coming from.

    Sean

    Comment

    • Jose Cintron

      #3
      Re: XML Parsing

      Thanks a million... Changed the line to
      XmlReader^ rdr = XmlReader::Crea te("Vulnerabili ties.xml");
      and all of the sudden it works.
      "Sean M. DonCarlos" <serenseven@new sgroups.nospam> wrote in message
      news:CB0ABF0B-E8BC-4179-A295-020FB1248040@mi crosoft.com...[color=blue]
      > "Jose Cintron" wrote:
      >[color=green]
      >> ...
      >> ..\XMLparse.cpp (16) : error C3622: 'System::Xml::X mlReader': a class
      >> declared
      >> as 'abstract' cannot be instantiated[/color]
      >
      > Correct. You can't directly create XmlReader objects with gcnew.
      >[color=green]
      >> ..\XMLparse.cpp (16) : error C3673: 'System::Xml::X mlReader' : class does
      >> not
      >> have a copy-constructor[/color]
      >
      > Also correct, because XmlReader is abstract.
      >[color=green]
      >> Just in case it makes a difference I'm using Visual C++ Express Edition.
      >> Any ideas will be greatly appreciated[/color]
      >
      > See the System::Xml::Xm lReader.Create( ...) family of methods. You can
      > create
      > various kinds of XmlReaders there, depending on where your XML is coming
      > from.
      >
      > Sean
      >[/color]


      Comment

      • Jose Cintron

        #4
        Re: XML Parsing

        OK the code looks as follows now...

        --- Start Code ---
        #include "stdafx.h"
        #using <mscorlib.dll >
        #using <System.xml.dll >

        using namespace System;
        using namespace System::Xml;

        int _tmain(int argc, _TCHAR* argv[])
        {
        try
        {
        // Create the reader...
        XmlReader^ rdr = XmlReader::Crea te("Vulnerabili ties.xml");
        while (rdr->ReadToFollowin g("VULNERABILIT Y"))
        {
        Console::WriteL ine("ID:" + rdr->GetAttribute(" ID"));
        }
        }
        catch (Exception^ pe)
        {
        Console::WriteL ine(pe->ToString());
        }
        return 0;
        }
        --- End Code ---

        My problem now is with the GetAttribute function. From what I read in MSDN
        it should move to the Attribute specified in the string "ID" and return its
        value. Is my understanding correct? If it is why is this damn thing not
        working? The while loop works just fine and I know that there is an ID
        entry for every VULNERABILITY.

        "Sean M. DonCarlos" <serenseven@new sgroups.nospam> wrote in message
        news:CB0ABF0B-E8BC-4179-A295-020FB1248040@mi crosoft.com...[color=blue]
        > "Jose Cintron" wrote:
        >[color=green]
        >> ...
        >> ..\XMLparse.cpp (16) : error C3622: 'System::Xml::X mlReader': a class
        >> declared
        >> as 'abstract' cannot be instantiated[/color]
        >
        > Correct. You can't directly create XmlReader objects with gcnew.
        >[color=green]
        >> ..\XMLparse.cpp (16) : error C3673: 'System::Xml::X mlReader' : class does
        >> not
        >> have a copy-constructor[/color]
        >
        > Also correct, because XmlReader is abstract.
        >[color=green]
        >> Just in case it makes a difference I'm using Visual C++ Express Edition.
        >> Any ideas will be greatly appreciated[/color]
        >
        > See the System::Xml::Xm lReader.Create( ...) family of methods. You can
        > create
        > various kinds of XmlReaders there, depending on where your XML is coming
        > from.
        >
        > Sean
        >[/color]


        Comment

        Working...