Solved

Formatting XML child parent structure

Posted on 2015-02-12
4
30 Views
Last Modified: 2015-03-04
I am trying to figure out how to structure my xml document to show
a state as a parent and the counties of that state as its children.
I  have attached a copy of the file.  Am I doing this correctly?
countystates.xml
0
Comment
Question by:cookiejar
  • 2
4 Comments
 
LVL 13

Expert Comment

by:Mark Bullock
Comment Utility
Move the following to the line after the last county in your state:  </state>

The idea is that the county tags are in between the opening state tag <state ...> and the closing state tag </state>
0
 

Author Comment

by:cookiejar
Comment Utility
Just to see if I understood.  Is the following correct?  I want to add other states as well with their counties.

<?xml version="1.0"?>
<statecounty>

      <state weather="rainy">Washington      
            <county>
              <name>Franklin County</name>
              <countyseat>Pasco</countyseat>
              <established>1883</established>
              <origin>Whitman County</origin>
              <population>17,863</population>
            </county>                        
      </state>
     
       <state weather="sunny">California      
            <county>
              name>Los Angeles</name>
              <countyseat>Los Angeles</countyseat>
              <established>1850</established>
              <origin>Los Angeles</origin>
              <population>10,017,068</population>            
             </county>                        
      </state>
      
</statecounty>
0
 
LVL 13

Expert Comment

by:Mark Bullock
Comment Utility
Yes that is valid XML.
You can open your .xml file in Chrome or Firefox (and maybe Internet Explorer) and it will show you a nice indented view if your syntax is correct.
0
 
LVL 35

Accepted Solution

by:
mccarl earned 500 total points
Comment Utility
I would also move the name of the sate into either it's own element or an attribute of the state element, such as...

<state weather="sunny">
  <name>California</name>
  <county>
  ...
  </county>
</state>

Open in new window


...or...
<state weather="sunny" name="California">
  <county>
  ...
  </county>
</state>

Open in new window

0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
This video discusses moving either the default database or any database to a new volume.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now