• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 329
  • Last Modified:

xmlreader presenting all data on screen vb.net, asp.net

Hi All,

I have been tasked with obtianing information from an xml dataset this morning and presenting all of the information from the XML data on the page.

I have only ever looked for a specific line within an xml file before so feel a little out of my depth and have no real idea how i need to do this.

The nods that I need to obtain information from are as below.

- <item cat1="Beet Intake" cat2="Fluming" cat3="" cat4="">
  <id>11602DB142D59C068025791F004E6459</id>
  <masterid />
  <parentid />
  <author>Critchlow John</author>
  <shift>Mornings</shift>
  <actualday>05/10/2011</actualday>
  <None />
  <None />
  <None />
- <content>
- <![CDATA[ <p> lost of text here....</p>
  </content>
  </item>

my task is to get them into an aspx page that will display the data without issue.

It also looks like the  within the <content> node has all sorts of html tags in them and wonder if these tags will show when presenting the information.

Also if anyone can show me how to use a repeater to show all records I would be very grateful.

Any and all help will be very much appreciated.
0
SimonPrice33
Asked:
SimonPrice33
  • 5
  • 5
1 Solution
 
käµfm³d 👽Commented:
You could do something like this in your markup:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="_27380966._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Repeater ID="Repeater1" runat="server" DataSourceID="XmlDataSource1">
            <ItemTemplate>
                <div>
                    ID:
                    <asp:Label ID="Label1" runat="server" Text='<%# XPath("id") %>' />
                </div>
                <div>
                    Author:
                    <asp:Label ID="Label2" runat="server" Text='<%# XPath("author") %>' />
                </div>
                <div>
                    Shirt:
                    <asp:Label ID="Label3" runat="server" Text='<%# XPath("shift") %>' />
                </div>
                <div>
                    Actual Day:
                    <asp:Label ID="Label4" runat="server" Text='<%# XPath("actualday") %>' />
                </div>
                <div>
                    Content:
                    <asp:Label ID="Label5" runat="server" Text='<%# HttpUtility.HtmlEncode(XPath("content")) %>' />
                </div>
            </ItemTemplate>
        </asp:Repeater>
        <asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="input.xml" XPath="//item" />
    </div>
    </form>
</body>
</html>

Open in new window


As for the "content" node, do you want the HTML to be processed as HTML, or displayed as raw text? I believe by default it will be rendered, but if you want it to be raw text, you could change line 31 to:

<asp:Label ID="Label5" runat="server" Text='<%# HttpUtility.HtmlEncode(XPath("content")) %>' />

Open in new window

0
 
SimonPrice33Author Commented:
HI Kaufmed,

Thanks for this, the data comes through but with all the HTML tags within the text in the same way its been entered into the XML from a Lotus Notes Domino Agent. Which I have no access or control over.

Any thoughts on how I could get around this?
0
 
käµfm³d 👽Commented:
Thanks for this, the data comes through but with all the HTML tags within the text in the same way its been entered into the XML from a Lotus Notes Domino Agent. Which I have no access or control over.
Ok, but do you want to display the embedded HTML as HTML, or as raw text?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
SimonPrice33Author Commented:
I would like to display it as HTML if possible.
0
 
käµfm³d 👽Commented:
Then the original code snippet ( http:#codeSnippet20-36916563-1 ) should work--at least it appeared to in my testing. Are you experiencing otherwise?
0
 
SimonPrice33Author Commented:
below is the output of what we see on screen.

<P><STRONG>Slicers :-</STRONG> Knife blocks changed in No's 1 &amp; 3</P> <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; No 1 cossttte belt stopped / started for removal / fitting of spray bar by engs.</P> <P><STRONG>Gp's :-</STRONG> No's 1 / 2 &amp; 3 pressure washed.</P> <P><STRONG>Clarifier :-</STRONG> Ratios dropped 0.02 / 0.01 &amp; 0.02 from top to&nbsp;bottom respectively.</P> <P><STRONG>Dlp's :-</STRONG> G &amp;&nbsp;G ( Gerry &amp;&nbsp;Graham ) working on&nbsp;presses.</P> <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Fill volumes dropped to 7.5m3.</P> <P><STRONG>Heaters :-</STRONG> No 6 raw&nbsp; juice htr available.</P> <P><STRONG>Towers :-</STRONG> Draft ratios dropped 0.01 &amp; 0.02 to 1.22 &amp; 1.05 respectively.</P> <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Formaldehyde timers dropped x 2 secs to 13 &amp; 3 secs.</P> <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Acid strength measured at 3.3%.</P> <P><STRONG>Pulp Presses :-</STRONG> Sequence taken off initially by No 9 pressed&nbsp;scroll, then had fleeting low oil pressure across all press oil p/p's taking presses off.</P> <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Timed out &amp; presses / seq re-started only for no 8 pressed scroll to take us off, elecs in attendance then seq re-started once again.</P> <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; No 1 press slide shut &amp; run empty, then stopped for welders to repair as screen gone again.</P>
0
 
SimonPrice33Author Commented:
although th ecode in teh snippet looks to be the same as that in the previous example.
0
 
käµfm³d 👽Commented:
That's my fault. I copied an updated version to that snippet. In the original code, change line 31 from:

<asp:Label ID="Label5" runat="server" Text='<%# HttpUtility.HtmlEncode(XPath("content")) %>' />

Open in new window


to:

<asp:Label ID="Label5" runat="server" Text='<%# XPath("content") %>' />

Open in new window



although th ecode in teh snippet looks to be the same as that in the previous example.
That's because it is the same code! I linked to the snippet so would go to the exact code I was referring to when you clicked it  = )
0
 
SimonPrice33Author Commented:
thanks
0
 
käµfm³d 👽Commented:
NP, glad to help. Sorry for the bungle on the initial post  = )
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now