Selecting Nodes using doc.selectnode()

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • libish
    New Member
    • Oct 2008
    • 42

    Selecting Nodes using doc.selectnode()

    hi all,
    i have an xml document. it contains several nodes...
    here i want to select a particular node containing the name say "$abc"
    so i'm using this

    docXML3.SelectN odes("$abc=*abc *123");

    but here an exception is raised telling that the expression ("$abc=*abc *123" )not supported.
    what should i do to avoid this situation?

    thanks in advance.
  • markmcgookin
    Recognized Expert Contributor
    • Dec 2006
    • 648

    #2
    Originally posted by libish
    hi all,
    i have an xml document. it contains several nodes...
    here i want to select a particular node containing the name say "$abc"
    so i'm using this

    docXML3.SelectN odes("$abc=*abc *123");

    but here an exception is raised telling that the expression ("$abc=*abc *123" )not supported.
    what should i do to avoid this situation?

    thanks in advance.
    Is this in .Net? Please post a bit more about your environment.

    Comment

    • libish
      New Member
      • Oct 2008
      • 42

      #3
      Originally posted by markmcgookin
      Is this in .Net? Please post a bit more about your environment.
      yes it is in c#.Net.

      here what i'm doing is.. i got an xml file containing parameters for my application
      the parameter names are represented by "$parametername "
      here in my xml file the parameter will be like

      <var>
      <v>"$para=12343 "</v>
      <v>"$para2=*hag r"</v>
      </var>

      at some point in my project i wll be in need to change the parameter value for
      "$para"

      this is how this situation arised...
      here i need to modify the node with new values...
      for that what should i do?

      Comment

      • markmcgookin
        Recognized Expert Contributor
        • Dec 2006
        • 648

        #4
        Originally posted by libish
        yes it is in c#.Net.

        here what i'm doing is.. i got an xml file containing parameters for my application
        the parameter names are represented by "$parametername "
        here in my xml file the parameter will be like

        <var>
        <v>"$para=12343 "</v>
        <v>"$para2=*hag r"</v>
        </var>

        at some point in my project i wll be in need to change the parameter value for
        "$para"

        this is how this situation arised...
        here i need to modify the node with new values...
        for that what should i do?
        Try something like this

        Code:
        XmlDocument.xmlDetails = new XmlDocument();
        xmlDetails.Load(@"MyDir\Templates\Setup.xml");
        XmlNodeList nodeList = xmlDetails.GetElementsByTagName("Settings");
        
                        foreach (XmlElement elem in nodeList)
                        {
                            foreach (XmlElement tempElem in elem.ChildNodes)
                            {
                                if (tempElem.Name == "Setup")
                                {
                                    myString Variable = tempElem.InnerText;
                                }
                                if (tempElem.Name == "Value")
                                {
                                    tempElem.InnerText = "A string value";
                                }
                             }
                          }
        
        xmlDetails.save(@"MyDir\Templates\Setup.xml");

        Comment

        Working...