Quantcast
Viewing all articles
Browse latest Browse all 27015

XML parsing help

I have an xml document that I need certain information out of: The document is a series of mini xml documents and has some unwanted text at the beginning. With the help of some in this forum, I have the unwanted string removed, and the document is being read in line by line with each xml file being a line. Because each of my xml files contains a different number of nodes I find that the xml text reader isn't a good option for pulling the information I need. I now have it loading as an xml document, but whenever I try to pull information from my lines, I get a null value. I am attaching an image of one of the xml files with the information that I need to extract bolded. There will be other lines where I need more information, but if I can get it to work once, I can figure out how to get the rest. And my code is below: I am trying to populate the variable sAccessDate with the EventDateTime within the xml file.
Image may be NSFW.
Clik here to view.
Name:  xml.PNG
Views: 23
Size:  18.9 KB


For Each sXML As String In IO.File.ReadAllLines("\\mypath\myfile.log")

sXML = sXML.Substring(sXML.IndexOf("<?xml")) ' chop off the bit that causes problems
Dim M_xml As New XmlDocument

Dim m_nodelist As XmlNodeList
Dim m_node As XmlNode
M_xml.LoadXml(sXML)

sAccessDateTime = M_xml.DocumentElement.Attributes.ItemOf("EventDateTime").InnerText <--when I step through this step is when I get the null reference error. I also tried .innerxml here.

Console.WriteLine(sAccessDateTime)
Console.ReadKey()
Next

ANy ideas on how to extract the info I need. I have been trialing and erroring for about 2 hours. (I am very new to this and could be missing something silly)

Here is what my m_xml variable loads with:
>? m_xml
{System.Xml.DebuggerDisplayXmlNodeProxy}
Attributes: Nothing
BaseURI: ""
ChildNodes: {System.Xml.XmlChildNodes}
DocumentElement: {System.Xml.DebuggerDisplayXmlNodeProxy}
DocumentType: Nothing
FirstChild: {System.Xml.DebuggerDisplayXmlNodeProxy}
HasChildNodes: True
Implementation: {System.Xml.XmlImplementation}
InnerText: ""
InnerXml: "<?xml version="1.0" encoding="UTF-8"?><AuditMessage xmlns:xsi="http://www.w3.org" xsi:noNamespaceSchemaLocation="http://someinfohere.xsd"><EventIdentification EventActionCode="E" EventDateTime="20130528133848" EventID="300_SignInError" EventOutcomeIndicator="4"></EventIdentification><UserIdentification UserID="abc123"></UserIdentification><AuditSourceIdentification AuditSourceID="HorizonWP Physician Portal" AuditSourceType="3"></AuditSourceIdentification><NetworkAccessPointIdentification NetworkAccessPointID="hostname.something.org" NetworkAccessPointTypeCode="1"></NetworkAccessPointIdentification><NetworkAccessPointIdentification NetworkAccessPointID="192.168.1.1 : null" NetworkAccessPointTypeCode="2"></NetworkAccessPointIdentification></AuditMessage>"
IsReadOnly: False
Item: In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user.
LastChild: {System.Xml.DebuggerDisplayXmlNodeProxy}
LocalName: "#document"
Name: "#document"
NamespaceURI: ""
NameTable: {System.Xml.NameTable}
NextSibling: Nothing
NodeType: Document {9}
OuterXml: "<?xml version="1.0" encoding="UTF-8"?><AuditMessage xmlns:xsi="http://www.w3.org" xsi:noNamespaceSchemaLocation="http://someinfohere.xsd"><EventIdentification EventActionCode="E" EventDateTime="20130528133848" EventID="300_SignInError" EventOutcomeIndicator="4"></EventIdentification><UserIdentification UserID="abc123"></UserIdentification><AuditSourceIdentification AuditSourceID="HorizonWP Physician Portal" AuditSourceType="3"></AuditSourceIdentification><NetworkAccessPointIdentification NetworkAccessPointID="hostname.something.org" NetworkAccessPointTypeCode="1"></NetworkAccessPointIdentification><NetworkAccessPointIdentification NetworkAccessPointID="192.168.1.1 : null" NetworkAccessPointTypeCode="2"></NetworkAccessPointIdentification></AuditMessage>"
OwnerDocument: Nothing
ParentNode: Nothing
Prefix: ""
PreserveWhitespace: False
PreviousSibling: Nothing
SchemaInfo: {System.Xml.Schema.XmlSchemaInfo}
Schemas: {System.Xml.Schema.XmlSchemaSet}
Value: Nothing
Attached Images
Image may be NSFW.
Clik here to view.
 

Viewing all articles
Browse latest Browse all 27015

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>