Error loading an XML file into XMLDocument

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anuanusha29
    New Member
    • Apr 2007
    • 10

    Error loading an XML file into XMLDocument

    Hi, I have pasted the xml file below. When I try to load this xmlfile into an instance of xml document, it gives "Root element missing ".
    I tried to check the well formedness and xpath queries in xmlspy and things looked fine to me.
    <?xml version="1.0" encoding="utf-8" ?>
    <Tasks>
    <Task Name="My Task" Prime="2" Description="So me name">
    <Server>SMSPAP1 171M:8080</Server>
    <Server>SMSPAP1 171M:8180</Server>
    </Task>
    </Tasks>

    Please tell whats wrong with this xml file.
    Additionally, when I need to add a new task from the UI, how to I add it as the last element(I need to keep the all the existing ones and add this new task at the end of the file before </Tasks>) using xml writer?????
  • stuinstra35
    New Member
    • May 2007
    • 2

    #2
    I believe you need to make the Task Name line a single entity node.(correct term?) Try:
    <?xml version="1.0" encoding="utf-8" ?>
    <Tasks>
    <Task Name="My Task" Prime="2" Description="So me name" />
    <Server>SMSPAP1 171M:8080</Server>
    <Server>SMSPAP1 171M:8180</Server>
    </Tasks>

    Originally posted by anuanusha29
    <?xml version="1.0" encoding="utf-8" ?>
    <Tasks>
    <Task Name="My Task" Prime="2" Description="So me name">
    <Server>SMSPAP1 171M:8080</Server>
    <Server>SMSPAP1 171M:8180</Server>
    </Task>
    </Tasks>

    Comment

    • anuanusha29
      New Member
      • Apr 2007
      • 10

      #3
      But then, Task is supposed to be an element with those attaributes(Nam e, prime, description) and child nodes Server, occurance unbounded.


      Originally posted by stuinstra35
      I believe you need to make the Task Name line a single entity node.(correct term?) Try:
      <?xml version="1.0" encoding="utf-8" ?>
      <Tasks>
      <Task Name="My Task" Prime="2" Description="So me name" />
      <Server>SMSPAP1 171M:8080</Server>
      <Server>SMSPAP1 171M:8180</Server>
      </Tasks>

      Comment

      Working...