none
binding xml data to repeater in infopath 2007 programitically RRS feed

  • Question

  • <?xml version=""1.0""?>
                        <!-- comment at the root level -->
                        <Products>
                          <Product Title='1ms Ultra Inert'>
                            <PartNumber>
                              <Title>devendra</Title>
                              <PartNo>122-0112UI</PartNo>
                              <Description>DB-1ms Ultra Inert, 15 m, 0.25 mm, 0.25 µm</Description>
                              <Url>http://</Url>
                            </PartNumber>
                            <PartNumber>
                              <Title>Ramesh</Title>
                              <PartNo>19091S-911UI</PartNo>
                              <Description>HP-1ms Ultra Inert, 15 m, 0.32 mm, 0.25 µm</Description>
                              <Url>http://</Url>
                            </PartNumber>
                          </Product>
                          <Product Title='DB-35ms Ultra Inert'>
                            <PartNumber>
                              <Title>rahim</Title>
                              <PartNo>122-3812UI</PartNo>
                              <Description>DB-35ms, Ultra Inert, 15 m, 0.25 mm, 0.25 µm</Description>
                              <Url>http://</Url>
                            </PartNumber>
                          </Product>
                        </Products>
    


    how i can show the above xml data in  arepeater control in infopath 2007.

     

    Thanks,

    Devendra



    MCTS,MCPD Sharepoint 2010. My Blog- http://www.sharepoint-journey.com
    If a post answers your question, please click "Mark As Answer" on that post and "Vote as Helpful

    Friday, August 26, 2011 10:41 AM

Answers

  • Hi Devendra,

    I found you also posted the problem on the Asp.net forum:

    http://forums.asp.net/p/1714615/4571065.aspx/1?Re+showing+the+below+xml+data+in+repeater+table+in+infopath

    , some experts have replied to you, but you haven't responsed.

    Just Reference Deckers solution:

    var result = from e in XDocument.Load("xxx.xml").Descedants("PartNumber")
    select new
    {
    Title = e.Element("Title").Value,
    PartNo = e.Element("PartNo").Value,
    Description = e.Element("Description").Value,
    Url = e.Element("Url").Value
    };

     

    Your repeater looks like

     

    <asp:Repeater ……>

     

    <ItemTemplate>

     

    <%#Eval("Title")%>

     

    <!--Other public properties...--->

     

    </ItemTemplate>

     

    </asp:Repeater>

    Do the suggestions there help you? Just feel free to let us know after you have tried.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Bruce Song Monday, September 5, 2011 11:40 AM
    Monday, August 29, 2011 9:18 AM
  • i got the solution

    XPathNavigator mainNav = MainDataSource.CreateNavigator();
                XPathNavigator Products = mainNav.SelectSingleNode("/my:myFields/my:group11", NamespaceManager);
                XPathNavigator Product = Products.SelectSingleNode("my:group12", NamespaceManager);
                XPathNavigator PartNumber = Product.SelectSingleNode("my:group13", NamespaceManager);
                XPathNavigator PartNumberrepTable = PartNumber.SelectSingleNode("my:group14", NamespaceManager);
                XPathNavigator PartNumbernode;
                int counter = 0;

                foreach (XElement pnsub in xmlDoc.Descendants("PartNumber"))
                {

                    PartNumbernode = PartNumberrepTable.Clone();
                    if (pnsub.HasElements)
                    {
                        PartNumbernode.SelectSingleNode("my:field22", NamespaceManager).SetValue(pnsub.Element("Title").Value);
                        PartNumbernode.SelectSingleNode("my:field23", NamespaceManager).SetValue(pnsub.Element("PartNo").Value);
                        PartNumbernode.SelectSingleNode("my:field24", NamespaceManager).SetValue(pnsub.Element("Description").Value);
                        PartNumbernode.SelectSingleNode("my:field25", NamespaceManager).SetValue(pnsub.Element("Url").Value);
                        PartNumber.AppendChild(PartNumbernode);
                        counter += 1;
                    }

                }
                //delete a specific range of nodes
                XPathNodeIterator rows = PartNumber.Select("my:group14", NamespaceManager);
                XPathNavigator first = PartNumber.SelectSingleNode("my:group14[1]", NamespaceManager);
                XPathNavigator second = PartNumber.SelectSingleNode("my:group14[" + Convert.ToString(rows.Count - counter) + "]", NamespaceManager);

                first.DeleteRange(second);



    MCTS,MCPD Sharepoint 2010. My Blog- http://www.sharepoint-journey.com
    If a post answers your question, please click "Mark As Answer" on that post and "Vote as Helpful

    Tuesday, September 20, 2011 10:30 AM

All replies

  • Hi Devendra,

    I found you also posted the problem on the Asp.net forum:

    http://forums.asp.net/p/1714615/4571065.aspx/1?Re+showing+the+below+xml+data+in+repeater+table+in+infopath

    , some experts have replied to you, but you haven't responsed.

    Just Reference Deckers solution:

    var result = from e in XDocument.Load("xxx.xml").Descedants("PartNumber")
    select new
    {
    Title = e.Element("Title").Value,
    PartNo = e.Element("PartNo").Value,
    Description = e.Element("Description").Value,
    Url = e.Element("Url").Value
    };

     

    Your repeater looks like

     

    <asp:Repeater ……>

     

    <ItemTemplate>

     

    <%#Eval("Title")%>

     

    <!--Other public properties...--->

     

    </ItemTemplate>

     

    </asp:Repeater>

    Do the suggestions there help you? Just feel free to let us know after you have tried.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Bruce Song Monday, September 5, 2011 11:40 AM
    Monday, August 29, 2011 9:18 AM
  • i got the solution

    XPathNavigator mainNav = MainDataSource.CreateNavigator();
                XPathNavigator Products = mainNav.SelectSingleNode("/my:myFields/my:group11", NamespaceManager);
                XPathNavigator Product = Products.SelectSingleNode("my:group12", NamespaceManager);
                XPathNavigator PartNumber = Product.SelectSingleNode("my:group13", NamespaceManager);
                XPathNavigator PartNumberrepTable = PartNumber.SelectSingleNode("my:group14", NamespaceManager);
                XPathNavigator PartNumbernode;
                int counter = 0;

                foreach (XElement pnsub in xmlDoc.Descendants("PartNumber"))
                {

                    PartNumbernode = PartNumberrepTable.Clone();
                    if (pnsub.HasElements)
                    {
                        PartNumbernode.SelectSingleNode("my:field22", NamespaceManager).SetValue(pnsub.Element("Title").Value);
                        PartNumbernode.SelectSingleNode("my:field23", NamespaceManager).SetValue(pnsub.Element("PartNo").Value);
                        PartNumbernode.SelectSingleNode("my:field24", NamespaceManager).SetValue(pnsub.Element("Description").Value);
                        PartNumbernode.SelectSingleNode("my:field25", NamespaceManager).SetValue(pnsub.Element("Url").Value);
                        PartNumber.AppendChild(PartNumbernode);
                        counter += 1;
                    }

                }
                //delete a specific range of nodes
                XPathNodeIterator rows = PartNumber.Select("my:group14", NamespaceManager);
                XPathNavigator first = PartNumber.SelectSingleNode("my:group14[1]", NamespaceManager);
                XPathNavigator second = PartNumber.SelectSingleNode("my:group14[" + Convert.ToString(rows.Count - counter) + "]", NamespaceManager);

                first.DeleteRange(second);



    MCTS,MCPD Sharepoint 2010. My Blog- http://www.sharepoint-journey.com
    If a post answers your question, please click "Mark As Answer" on that post and "Vote as Helpful

    Tuesday, September 20, 2011 10:30 AM