Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8791379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:50:06+00:00 2026-06-13T22:50:06+00:00

I have this XML document I am trying to read in and insert into

  • 0

I have this XML document I am trying to read in and insert into a data base. There will only ever be one GamePlay node however GamePlayStep may repeat so I have created a node list for this. For some reason GamePlayStep isn’t receiving data. Here is the XML file:

<?xml version="1.0" encoding="utf-8" ?>
<GameData>
  <GamePlay>
    <type>add</type>
    <GamePlayID>1</GamePlayID>
    <ParticipantID>1</ParticipantID>
    <GameID>1</GameID>
    <GameDifficultyID>1</GameDifficultyID>
    <Start>2012-08-06T12:19:33.154Z</Start>
    <End>2012-08-06T12:30:33.154Z</End>
    <Success>False</Success>
  </GamePlay>
  <GamePlayStep>
    <GamePlayStepID>1</GamePlayStepID>
    <Start>2012-08-06T12:19:33.154Z</Start>
    <End>2012-08-06T12:30:33.154Z</End>
    <SortOrder>1</SortOrder>
    <Score>1</Score>
    <hintUsed>True</hintUsed>
    <GamePause>
      <GamePauseID>1</GamePauseID>
      <Start>2012-08-06T12:19:33.154Z</Start>
      <End>2012-08-06T12:30:33.154Z</End>
      <Order>1</Order>
      <Duration>05:01</Duration>
    </GamePause>
  </GamePlayStep>
</GameData>

Here is my code:

public static void start()
        {
            string[] filePaths = Directory.GetFiles(System.Configuration.ConfigurationManager.ConnectionStrings["filePath"].ConnectionString);
            List<GamePlay> gameObj = new List<GamePlay>();
            List<GamePlayStep> gameStepObj = new List<GamePlayStep>();
            foreach (string value in filePaths)
            {
                XmlDocument xd = new XmlDocument();
                XmlNodeList GameSteps;
                xd.Load(value);
                XmlNode documentNode = xd.SelectSingleNode("/GameData/GamePlay");
                GameSteps = xd.SelectNodes("/GameData/GamePlay/GamePlayStep");

                GamePlay newGamePlay = new GamePlay();
                newGamePlay.setType(Convert.ToString(documentNode.SelectSingleNode("type").InnerText));
                newGamePlay.setGamePlayID(Convert.ToInt32(documentNode.SelectSingleNode("GamePlayID").InnerText));
                newGamePlay.setParticipantID(Convert.ToInt32(documentNode.SelectSingleNode("ParticipantID").InnerText));
                newGamePlay.setGameDifficultyID(Convert.ToInt32(documentNode.SelectSingleNode("GameDifficultyID").InnerText));
                newGamePlay.setGameID(Convert.ToInt32(documentNode.SelectSingleNode("GameID").InnerText));
                newGamePlay.setStartDateTime(Convert.ToDateTime(documentNode.SelectSingleNode("Start").InnerText));
                newGamePlay.setEndDateTime(Convert.ToDateTime(documentNode.SelectSingleNode("End").InnerText));
                newGamePlay.setSuccess(Convert.ToBoolean(documentNode.SelectSingleNode("Success").InnerText));
                newGamePlay.setFile(value);
                newGamePlay.addNewGamePlay();

                foreach (XmlNode documentNode2 in GameSteps)
                {

                    GamePlayStep newGamePlayStep = new GamePlayStep();
                    newGamePlayStep.setGamePlayStepID(Convert.ToInt32(documentNode2.SelectSingleNode("GamePlayStepID").InnerText));
                    newGamePlayStep.setGamePlayID(newGamePlay.getGamePlayID());
                    newGamePlayStep.setStartDateTime(Convert.ToDateTime(documentNode2.SelectSingleNode("Start").InnerText));
                    newGamePlayStep.setEndDateTime(Convert.ToDateTime(documentNode2.SelectSingleNode("End").InnerText));
                    newGamePlayStep.setOrderPlayed(Convert.ToInt32(documentNode2.SelectSingleNode("SortOrder").InnerText));
                    newGamePlayStep.setScore(Convert.ToInt32(documentNode2.SelectSingleNode("Score").InnerText));
                    newGamePlayStep.setHintUsed(Convert.ToBoolean(documentNode2.SelectSingleNode("hintUsed").InnerText));
                    newGamePlayStep.addNewGamePlayStep();


                }

            }
        }

The GamePlay is filling the variables properly and inserting into the database however the GamePlaySteps in the NodeList are not. Does anyone see the problem or how I can improve this?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:50:07+00:00Added an answer on June 13, 2026 at 10:50 pm

    Your XPath for accessing the GamePlayStep is incorrect;

    It should be:

    GameSteps = xd.SelectNodes("/GameData/GamePlayStep");
    

    As GamePlayStep is a child of GameData, not GamePlay, in your document.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple XML document I'm trying to read in with Python DOM
Hello I am trying to read my xml document using xpath. I have been
We are trying to read information from a separate XML document. This is the
I have this XML document <xml> <word> <threeletter>rip</threeletter> <fourletter>Pier</fourletter> <fiveletter>Spire</fiveletter> <sixletter>Spider</sixletter> </word> <word> <threeletter>rip</threeletter>
I have this kind of node in my xml document: <parent ...> <a .../>
I have an xml document that looks like this. <foo> <bar type=artist/> Bob Marley
I have a xml document like this : <Node1 attrib1=abc> <node1_1> <node1_1_1 attrib2 =
I have an XML document which looks something like this: <meadinkent> <record> <comp_div>MENSWEAR</comp_div> <sty_ret_type>ACCESSORIES</sty_ret_type>
I have an XML document that matches our site navigation something like this: <page
Hi I have an xml document like this <root> <cert id=1> </cert> <cert id=2>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.