I'm trying to parse a XML file and extract a few data elements. I'm having
trouble extracting the exact elements. I get the entire content of the XML
file in the text box currently. I can't figure out how to just get the
elements/attirbutes that I want. This is being done in Visual Web Developer
Express.
The code I have so far is:
Dim sr As New System.IO.StreamReader("C:\test123\upload\" +
FileUpload1.FileName)
Dim xr As New System.Xml.XmlTextReader(sr)
Dim m_xmld = New System.Xml.XmlDocument
Dim m_nodelist As System.Xml.XmlNodeList
Dim m_node As System.Xml.XmlNode
'Dim startdate As System.Xml.XmlNode
'Create the XML Document
'Load the Xml file
m_xmld.Load(xr)
m_nodelist =
m_xmld.SelectNodes("/TestMessage/AuthenticatedPublic/MessageId")
TextBox1.Text = m_xmld.getElementsByTagName("MessageId")
The XML file looks like this (partial):
<?xml version="1.0" encoding="UTF-8"?>
<TestMessage xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"
xmlns:enc="http://www.w3.org/2001/04/xmlenc#">
<AuthenticatedPublic Id="ID_AuthenticatedPublic">
<MessageId>urn:uuid:efeb77ff-eab6-4f4b-8fc8-d1f7293fec91</MessageId>
<MessageType>http://www.test123.com/PROTO-TEST-KDM-20040311#</MessageType>
<AnnotationText>TEST 123</AnnotationText>
<IssueDate>2006-01-30T21:31:32+00:00</IssueDate>
<Signer>
<dsig:X509IssuerName>/dnQualifier=JIQs8tRZIGKLLlyGkKOqMLonGpw=/O=dc.Root.ca.test_rje_xp_laptop.com/OU=test
RJE_XP_LAPTOP/CN=TMS.Test.2A51FBD4-58C2-4955-82FE-8FB31C15C0F7.v0.2.3.0</dsig:X509IssuerName>
<dsig:X509SerialNumber>b5:c9:ac:0a:83:e2:ef:d4
</dsig:X509SerialNumber>
</Signer> <RequiredExtensions>
<Recipient>
<X509IssuerSerial>
<dsig:X509IssuerName/>
<dsig:X509SerialNumber/>
</X509IssuerSerial> <X509SubjectName/>
</Recipient>
<CompositionPlaylistId>urn:uuid:d2b7595e-f852-f246-8c74-3d9724f923a8</CompositionPlaylistId>
<ContentTitleText>StEM_MM_2k_XYZ_CRYPT</ContentTitleText>
<ContentKeysNotValidBefore>2006-01-31T10:00:00+00:00</ContentKeysNotValidBefore>
<ContentKeysNotValidAfter>2006-02-28T09:59:00+00:00</ContentKeysNotValidAfter>