XML AND VB


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: XML AND VB

  1. #1
    venky Guest

    XML AND VB


    Hi

    I have an XML file, aportion of which is shown below. Can I use VB to read
    the elements of this file into variables ?

    <?xml version="1.0" ?>
    <!DOCTYPE HPD (View Source for full doctype...)>
    - <HPD>
    - <CRSRowset>
    - <CRSRow action="create">
    <Administration hpdcust_id="softbank" submitter_user="softbank" submitter_password="j1sst25m"
    />
    <FoundationBlock segment_nm="003" pers_give_nm="sandy" pers_last_nm="mohanraj"
    addr_nm="4 th ave" company_nm="softbank" bldg_ms_cd="344" addr_city_nm="test#Austin"
    state_cd="TX" zip_postal_cd="78780" addr_country_cd="US" email_add_nm="test@test.com"
    tele_country_access_cd="1" tele_city_cd="800" tele_phone_nr="090-9876" priv_email_cd="Y"
    priv_postal_cd="Y" priv_phone_cd="Y" priv_cd="Y" model_id="D7581A" prod_serial_id="07062000"
    purch_dt="07062000" install_dt="07062000" />
    <LibraryBlock priv_flag4ptnr_shar="001" />




  2. #2
    Anon Guest

    Re: XML AND VB


    Yes
    "venky" <vaiyar@hotmail.com> wrote:
    >
    >Hi
    >
    >I have an XML file, aportion of which is shown below. Can I use VB to read
    >the elements of this file into variables ?
    >
    > <?xml version="1.0" ?>
    > <!DOCTYPE HPD (View Source for full doctype...)>
    >- <HPD>
    >- <CRSRowset>
    >- <CRSRow action="create">
    > <Administration hpdcust_id="softbank" submitter_user="softbank" submitter_password="j1sst25m"
    >/>
    > <FoundationBlock segment_nm="003" pers_give_nm="sandy" pers_last_nm="mohanraj"
    >addr_nm="4 th ave" company_nm="softbank" bldg_ms_cd="344" addr_city_nm="test#Austin"
    >state_cd="TX" zip_postal_cd="78780" addr_country_cd="US" email_add_nm="test@test.com"
    >tele_country_access_cd="1" tele_city_cd="800" tele_phone_nr="090-9876" priv_email_cd="Y"
    >priv_postal_cd="Y" priv_phone_cd="Y" priv_cd="Y" model_id="D7581A" prod_serial_id="07062000"
    >purch_dt="07062000" install_dt="07062000" />
    > <LibraryBlock priv_flag4ptnr_shar="001" />
    >
    >
    >



  3. #3
    dave Guest

    Re: XML AND VB


    Yes,
    However you will need to use the MSHTML parser supplied by Microsoft. You
    can use this object either in VB or in a scripting situation. There are
    a number of tutorials listed at

    http://www.xmldir.com/directory.asp?dir=494

    Dave

    "venky" <vaiyar@hotmail.com> wrote:
    >
    >Hi
    >
    >I have an XML file, aportion of which is shown below. Can I use VB to read
    >the elements of this file into variables ?
    >
    > <?xml version="1.0" ?>
    > <!DOCTYPE HPD (View Source for full doctype...)>
    >- <HPD>
    >- <CRSRowset>
    >- <CRSRow action="create">
    > <Administration hpdcust_id="softbank" submitter_user="softbank" submitter_password="j1sst25m"
    >/>
    > <FoundationBlock segment_nm="003" pers_give_nm="sandy" pers_last_nm="mohanraj"
    >addr_nm="4 th ave" company_nm="softbank" bldg_ms_cd="344" addr_city_nm="test#Austin"
    >state_cd="TX" zip_postal_cd="78780" addr_country_cd="US" email_add_nm="test@test.com"
    >tele_country_access_cd="1" tele_city_cd="800" tele_phone_nr="090-9876" priv_email_cd="Y"
    >priv_postal_cd="Y" priv_phone_cd="Y" priv_cd="Y" model_id="D7581A" prod_serial_id="07062000"
    >purch_dt="07062000" install_dt="07062000" />
    > <LibraryBlock priv_flag4ptnr_shar="001" />
    >
    >
    >



  4. #4
    Guna Guest

    Re: XML AND VB


    Sure you can. If you want a solution email me at gmaniam@sageportfolio.com

    "venky" <vaiyar@hotmail.com> wrote:
    >
    >Hi
    >
    >I have an XML file, aportion of which is shown below. Can I use VB to read
    >the elements of this file into variables ?
    >
    > <?xml version="1.0" ?>
    > <!DOCTYPE HPD (View Source for full doctype...)>
    >- <HPD>
    >- <CRSRowset>
    >- <CRSRow action="create">
    > <Administration hpdcust_id="softbank" submitter_user="softbank" submitter_password="j1sst25m"
    >/>
    > <FoundationBlock segment_nm="003" pers_give_nm="sandy" pers_last_nm="mohanraj"
    >addr_nm="4 th ave" company_nm="softbank" bldg_ms_cd="344" addr_city_nm="test#Austin"
    >state_cd="TX" zip_postal_cd="78780" addr_country_cd="US" email_add_nm="test@test.com"
    >tele_country_access_cd="1" tele_city_cd="800" tele_phone_nr="090-9876" priv_email_cd="Y"
    >priv_postal_cd="Y" priv_phone_cd="Y" priv_cd="Y" model_id="D7581A" prod_serial_id="07062000"
    >purch_dt="07062000" install_dt="07062000" />
    > <LibraryBlock priv_flag4ptnr_shar="001" />
    >
    >
    >



  5. #5
    Sean Hester Guest

    Re: XML AND VB


    Venky,

    Yes, you can easily read information from an XML file into a VB variable
    (or leave it in the file and read the value directly when you need it).

    I'm going to give you an example using MSXML3--if you're using VB with XML,
    do yourself a favor and download Microsoft's latest parser now [http://msdn.microsoft.com/xml/general/msxmlprev.asp]!
    I know its beta, but its very solid. I'm using it in a production system
    already and haven't had any problems with it.

    1. With VB, you'll need to get an instance of an MSXML2.DOMDocument (don't
    ask me why the progID is MSXML2) like this:

    Set oDOMDocument = New MSXML2.DOMDocument (or user Server.CreateObject if
    your doing this inside an ASP)

    2. Load the xml string into the DOM
    oDOMDocument.loadXML <your XML string goes here>

    3. Use XPath to access the element value that you want. Let's say you need
    the value of the FoundationBlock element's segment_nm attribute. Your VB
    would look like this.

    sMyVar = oDOMDocument.selectSingleNode("//FoundationBlock/@segment_nm").Text

    The selectSingleNode method allows you to read the text value of the attribute
    segment_nm that is a child of a FoundationBlock element that is located anywhere
    within the XML document. You can also use it to copy elements from one document
    to another or into an IXMLDOMNode object.

    One word of caution--the .Text value is always a string data type. If your
    variable was typed as an integer or some other non-string type, you would
    need to convert it when you read it with CInt(*) or another appropriate data
    conversion.

    Hope this helps.


    "venky" <vaiyar@hotmail.com> wrote:
    >
    >Hi
    >
    >I have an XML file, aportion of which is shown below. Can I use VB to read
    >the elements of this file into variables ?
    >
    > <?xml version="1.0" ?>
    > <!DOCTYPE HPD (View Source for full doctype...)>
    >- <HPD>
    >- <CRSRowset>
    >- <CRSRow action="create">
    > <Administration hpdcust_id="softbank" submitter_user="softbank" submitter_password="j1sst25m"
    >/>
    > <FoundationBlock segment_nm="003" pers_give_nm="sandy" pers_last_nm="mohanraj"
    >addr_nm="4 th ave" company_nm="softbank" bldg_ms_cd="344" addr_city_nm="test#Austin"
    >state_cd="TX" zip_postal_cd="78780" addr_country_cd="US" email_add_nm="test@test.com"
    >tele_country_access_cd="1" tele_city_cd="800" tele_phone_nr="090-9876" priv_email_cd="Y"
    >priv_postal_cd="Y" priv_phone_cd="Y" priv_cd="Y" model_id="D7581A" prod_serial_id="07062000"
    >purch_dt="07062000" install_dt="07062000" />
    > <LibraryBlock priv_flag4ptnr_shar="001" />
    >
    >
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center