Link to home
Start Free TrialLog in
Avatar of Ewe kean tan
Ewe kean tan

asked on

XML how to start with ??any idea?

<accounts>
<savings_accounts>
<savings_account id="a1" interest="0.03">
<balance>2500</balance>
</savings_account>
<savings_account id="a2" interest="0.03">
<balance>15075</balance>
</savings_account>
</savings_accounts>
<checking_accounts>
<checking_account id="a3">
<balance>4025</balance>
</checking_account>
<checking_account id="a4">
<balance>-125</balance>
</checking_account>
<checking_account id="a5">
<balance>325</balance>
</checking_account>
</checking_accounts>
</accounts>
<customers>
<customer id="c1">
<name>Ben Richerdson</name>
<address>Park Drive 2</address>
</customer>
<customer id="c2">
<name>Marc Wretcher</name>
<address>Mill Drive 75</address>
</customer>
<customer id="c3">
<name>Angel Steady</name>
<address>Lake Sight 15</address>
</customer>
</customers>

<customer_accounts>
<customer_account c_id="c1" ac_id="a2"/>
<customer_account c_id="c1" ac_id="a3"/>
<customer_account c_id="c2" ac_id="a4"/>
<customer_account c_id="c3" ac_id="a1"/>
<customer_account c_id="c3" ac_id="a5"/>
</customer_accounts>
</bank>

Open in new window

Avatar of Nitin Sontakke
Nitin Sontakke
Flag of India image

Please be very explicit with what you are trying say / achieve here. Not sure what your question is. Please elaborate.
In what regard or context?

I would start with Syntax

Effective XML: 50 Specific Ways to Improve Your XML

0 REVIEWS
by Elliotte Rusty Harold
Publisher: Addison-Wesley Professional
Published: September 2003

If you want something more recent

C# and XML Primer
Publisher: Apress
Published: February 2017

These are 2 of about 300 books available for 40.00 per month at Safari Books Online.

I would focus more on
Pro RESTful APIs: Design, Build and Integrate with REST, JSON, XML and JAX-RS
by Sanjay Patni
Publisher: Apress
Published: March 2017

If the context is Powershell, I'll save that for another post.  I hope this provided some help.

Point being, XML can be a properties file for Powershell Script, is used in Windows Event Logs, and the information provided above is akin to asking for directions to the closest Starbucks and not providing your location.
Avatar of Ewe kean tan
Ewe kean tan

ASKER

Write a DTD for bank.xml based on the following:
 There are two types of bank account: checking account and savings account
 The account id is unique and required in 'accounts' and 'ac_id' refers to accounts
 The customer id is unique and required in 'customers' and 'c_id' refers to customers
 Use as specific content models for the elements as possible:
 Zero or more occurrence for savings_account element, checking_account element,
customer element and customer_account element
 Empty element is allowed for customer_account
 Include the DTD in the XML document
This is question about .. i new to XML ..any expert ppl can help ? guide me
This is just a broad and open thought. It might even be evil and dangerous from the 'purist' and 'academic' xml expert's view point. So, please feel free to ignore.

Typically, i would take trouble of taking the DTD path only if it is some sort of integration with other systems. If it is in-house development, i wouldn't worry too much. For example, if your application expected to receive xml files from other systems and you wish to validate them quickly then it is fine.
Your missing element information and more.  I'll leave the DTD relative to Bank alone but I you want a starting point and "new".  You have crossed over to the realm of a project.  Folks don't take kindly to doing your job for you.  That is why this site has project requests or job requests or whatever they call it now.

For example, I'll give you this https://www.one-tab.com/page/5ufBGYv0RomocIvFOLbqxw

A collection of material relative to DTD and XML.

I'm going to refer this to Gigs.  Others, might certainly disagree but what your asking has risks.
<?xml version = "1.0" encoding = "UTF-8" standalone = "yes" ?>
<!DOCTYPE bank
[
    
   <!ELEMENT bank (accounts,customers*)>
   <!ELEMENT accounts(savings_accounts,checking_account)> 
   <!ELEMENT savings_accounts (balance)>
   <!ELEMENT balance (#PCDATA)>
   <!ELEMENT checking_account (balance)>
   <!ELEMENT customers(name,address)>
   <!ELEMENT name (#PCDATA)>
   <!ELEMENT address (#PCDATA)>
   <!ELEMENT customer_accounts(#PCDATA)>
   <!ATTLIST saving_account ID CDATA #REQUIRED>
   <!ATTLIST checking_account ID CDATA #REQUIRED>
   <!ATTLIST Customer ID CDATA #REQUIRED>

]>

<bank>
   <accounts>
     <savings_accounts>
             <savings_account id="a1" interest="0.03">
             <balance>2500</balance>
              </savings_account>
   
             <savings_account id="a2" interest="0.03">
             <balance>15075</balance>
             </savings_account>
     </savings_accounts>
        <checking_accounts>
                <checking_account id="a3">
                <balance>4025</balance>
              </checking_account>
             <checking_account id="a4">
                <balance>-125</balance>
             </checking_account>
           <checking_account id="a5">
              <balance>325</balance>
            </checking_account>
       </checking_accounts>
   </accounts>
    <customers>
          <customer id="c1">
          <name>Ben Richerdson</name>
           <address>Park Drive 2</address>
          </customer>
      <customer id="c2">
      <name>Marc Wretcher</name>
        <address>Mill Drive 75</address>
      </customer>
     <customer id="c3">
         <name>Angel Steady</name>
        <address>Lake Sight 15</address>
     </customer>
      </customers>
        <customer_accounts>
          <customer_account c_id="c1" ac_id="a2"/>
          <customer_account c_id="c1" ac_id="a3"/>
           <customer_account c_id="c2" ac_id="a4"/>
               <customer_account c_id="c3" ac_id="a1"/>
           <customer_account c_id="c3" ac_id="a5"/>
</customer_accounts>
  
</bank>

Open in new window

can anyone help ? my xml got problem
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.