Very weird string problem
I have a VERY annoying string problem. I am importing an XML file and trying to read whats in between the tags. this is the last tag I have left and it doesn't make sense. This is a small clip of what is read from the file
Code:
<cp:revision>1</cp:revision>
<dcterms:created xsi:type="dcterms:W3CDTF">2009-03-18T16:03:00Z</dcterms:created>
<dcterms:modified xsi:type="dcterms:W3CDTF">2009-03-18T16:45:00Z</dcterms:modified>
</cp:coreProperties>
This is the code I'm using to get whats between the dcterms:created tags
Code:
tagStart = "<dcterms:created"
tagEnd = "</dcterms:created"
x = input.IndexOf(tagStart)
y = input.IndexOf(tagEnd)
If x = -1 Or y = -1 Then MessageBox.Show("iFailed")
Info.datecreated = input.Substring(x + 43, y - x)
Info.timecreated = input.Substring(x + 54, y - x)
but I get all this extra.
Code:
2009-03-18T16:03:00Z</dcterms:created><dcterms:modified xsi:typ
16:03:00Z</dcterms:created><dcterms:modified xsi:type="dcterms:
Why do i get so much extra stuff.
P.S. someone pointed me at the System.XML and i looked at it but im not entirely sure how to use it. I am still very new at programming. plus I have gotten so far doing it my way
Re: Very weird string problem
seems like it should have been
Code:
input.Substring(x + 43, y - (x+43))
input.Substring(x + 54, y - (x+54))
Re: Very weird string problem
Yeah, you really shouldn't be using string manipulation to work with XML. .NET has extensive support for XML handling so that's what you should use. Probably the easiest way to do this would be to create an XmlDocument, which is a member of System.Xml, and then pick out the individual elements you need. You should start by reading the documentation for the XmlDocument class and then search the web for examples. You can then give it a go and, if you have issues, post back here with what you've done and an explanation of the current problem.