Formatting XML child parent structure

Posted on 2015-02-12
Medium Priority
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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 14

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 14

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 36

Accepted Solution

mccarl earned 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

719 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