Formatting XML child parent structure

Posted on 2015-02-12
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?
Question by:cookiejar
  • 2
LVL 13

Expert Comment

by:Mark Bullock
ID: 40607299
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>

Author Comment

ID: 40608632
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"?>

      <state weather="rainy">Washington      
              <name>Franklin County</name>
              <origin>Whitman County</origin>
       <state weather="sunny">California      
              name>Los Angeles</name>
              <countyseat>Los Angeles</countyseat>
              <origin>Los Angeles</origin>
LVL 13

Expert Comment

by:Mark Bullock
ID: 40609370
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.
LVL 35

Accepted Solution

mccarl earned 500 total points
ID: 40611513
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">

Open in new window

<state weather="sunny" name="California">

Open in new window


Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

911 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

21 Experts available now in Live!

Get 1:1 Help Now