C# & XML - Object reference not set to an instance of an object - c#

Good Evening StackOverFlowers,
I have recently starting coding in XML via Visual Studio 2010. I have come across what seems to be a simple solution, yet the solution escapes me. I get an error for an Object Reference not set, but I don't see what I haven't set. (error here: http://i.imgur.com/CVaxY.png )
My codebehind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
public partial class _Default : System.Web.UI.Page
{
int intDVDID;
XmlDocument myXmlDocument = new XmlDocument();
XmlNode rootNode;
XmlNode selectedDVD;
public void Page_Load(object Src, EventArgs E)
{
intDVDID = Convert.ToInt32(Request.QueryString["id"]);
myXmlDocument.Load(Request.PhysicalApplicationPath + #"dvd.xml");
rootNode = myXmlDocument.DocumentElement;
selectedDVD = rootNode.ChildNodes[intDVDID - 1];
if (!Page.IsPostBack)
{
rootNode.RemoveChild(selectedDVD);
myXmlDocument.Save(Request.PhysicalApplicationPath + #"dvd.xml");
lblMessage.Text = "You have successfully deleted the DVD";
}
}
}
Is it just a matter of saying:
int intDVDID = new intDVDID
I know by reading this you're all going to want to pull your hair out at my inexperience and lack of understanding how to solve this, but I appreciate your time and your patience just looking.
Best regards,
Laura :)
Edit:
Here is my XML:
<?xml version="1.0" encoding="utf-8" ?>
<!-- This XML document describes a DVD library -->
<library>
<DVD id="1">
<title>Breakfast at Tiffany's</title>
<format>Movie</format>
<genre>Classic</genre>
</DVD>
<DVD id="2">
<title>Contact</title>
<format>Movie</format>
<genre>Science fiction</genre>
</DVD>
<DVD id="3">
<title>Little Britain</title>
<format>TV Series</format>
<genre>Comedy</genre>
</DVD>
</library>

It is looking like your selectedDVD may null, put some null checks to verify.
if(selectedDVD != null)
{
}
Edit: In response to your question in comments. Here is some example code. I threw in an xpath even though it seems your case is very simple you may want to use this in the future
string xml = "<xml><node id='1'></node><node id='2'></node></xml>";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(xml);
//This is an xpath(This replaces your .DocumentElement.ChildNodes[index]
XmlNode desiredNode = xmlDoc.DocumentElement.SelectSingleNode("node[#id='1']");
if (desiredNode != null)
{
xmlDoc.DocumentElement.RemoveChild(desiredNode);
}//if

Pleaase make sure that your query string is not empty it may cause you null reference exeption that you are geting.
if(Request.QueryString["id"]!="")
{
intDVDID = Convert.ToInt32(Request.QueryString["id"]);
}

Related

Remove Nodes Depending on Dynamic ID, C#, XML

I have this XML File
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Mobiles>
<Mobile ID="98a2d0b9c2661725a7486423ebd94abdef53ed89051ff5ac7a9c63a4b2a99d7a" RegDate="26/05/2017">
<FullName>Galaxy S-4</FullName>
<Vendor>Samsung</Vendor>
<Date>2010</Date>
<Price>30000SYP</Price>
<Weight>5g</Weight>
<Features>All</Features>
<Notifecations></Notifecations>
<Picture>/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCADCAQQDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCS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2r7BynytaaVqTyfurG5V/8AahZD/wCPAVoReG9fvJ9q6PqEjfd3fZ2I/wC+jwPzr6aoo9qxciPF/Dfwpv7idLjXkS0tV5a3Vg0r+xIyqj3BJ+nWvYoYo4YUiiVViRQqqvQAdAKmpKhyb3KSSFrzr4lfDC18cwJeW8q2eswLsjmZfklXqFfHOM9GHIyeD0r0WikM+PtU+G3jjQpmWXQbydS3+sso/PVvf5MkD6gVlnTNdi/4+NP1KD/f09/8K+1aK09oyeVHxOIbr+N51/7cWp6QzvIqLdy7mbaq/YXJY+gAHJr7VpMU/a+QcqPi0W100mxLiRnZtqr9hkzn0A29aPJuPu/a5d33dv2GT/CvtKil7RhynxcIL1/9VLct/u6e9S/2N4im/wBVp+sy/wDXPTXGfxxX2bRR7Rhyo+RNH+FHjPWpF8rRZ7RGPzTaj+5C+5B+b8lNfQnw8+Hdh4E06QJJ9p1K5A+03TLjgdEUdlH5k8nsB21LUuTY0rBRRRUjCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//2Q==</Picture>
</Mobile>
<Mobile ID='00283f5aa9c0c68c342c02977051757a7faae0ee70b086e628da7cc5baef2100' RegDate="26/05/2017">
<FullName>6600</FullName>
<Vendor>Nokia</Vendor>
<Date>2006</Date>
<Price>200SYP</Price>
<Weight>10g</Weight>
<Features>blutooth</Features>
<Notifecations></Notifecations>
<Picture>/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCABbAEUDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QA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boSqBtQcoMvMV8pCR02/dUjtklvTNN+DMjNHrELdN8cg/X/AAFDGtz1eiiipLCiiigDwD4iWP8AY3iW5hK/6Nct9rhGOzffH5lvzFcvoGuWuga/p8UiyR/Z5CjyRSMrSRv1yQc4HysOexr2b4s+Hf7X8JSXtuha80wNOm0ZZkx86j8ADj/ZFfO+pD7ZpsN9GoLwYSTjqvb+opkM+gXbNvJbtNqKsAGyiTEGUEHn5TgZA7k1EjLOwaKxup4ZMMBL5mCCMnIfC5zWH4F12LXdGtFbUFXUYRtkjlUZIUYVvvLuyAB3II5rZuLYQtMbu4XABBZI1QBQdyjLMw/j447UIRVJZ4bZLxyyoqoLWJiSMEDAIGA3HRQTxwRUXwbONS1ePttU/r/9eql5rdtp8Ej2BZ5A5IumYnGTnAfoRyRtQYOOcVo/CCxljn1W7ZCiMETkdCecfXGD/wACFNlI9ZoooqSgooooAayhhggEHqD3r5v8b+CbzwZrdzdWlk914fvCchRuEQPJVvTHY9MY719I0YHpQJo+U9K0S3uQJrSe8aBvuoNPkmz+KjFdvpXhvUxtNroepTt03C0itQP+BSkH8ga92ooFynmtn4B1K6nWbUJbWyUf3P8ASZ/wZgFX8FNd5pum22lWK2topWMckscsxPUk9yfWrtFBQtFFFAH/2Q==</Picture>
</Mobile>
</Mobiles>
When I try to remove Mobile element depending on IDtextbox.text rather than static value in XPath expression it doesn't execute
I'm using Windows application in Visual Studio 2010, C# language
I need two examples:
1- Depending on an element inside the parent element.
2- depending on an attribute of the parent element, make sure that attribute is not an integer value, it's code.
Notice: I have searched for many websites and view multiple solutions nobody mention about using control value in XPath expressions.
Use xml linq which is better in this case than xpath
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
namespace ConsoleApplication1
{
class Program
{
const string FILENAME = #"c:\temp\test.xml";
static void Main(string[] args)
{
XDocument doc = XDocument.Load(FILENAME);
List<XElement> mobiles = doc.Descendants("Mobile").ToList();
mobiles = mobiles.Where(x => (string)x.Element("FullName") != "Galaxy S-4").ToList();
mobiles = mobiles.Where(x => (string)x.Attribute("RegDate") != "26/05/2017").ToList();
doc.Descendants("Mobiles").FirstOrDefault().ReplaceWith(new XElement("Mobiles", mobiles));
}
}
}
thanks, Mr.jdweng
I solve the problem with this code
XDocument doc = XDocument.Load(#"Mobiles.xml");
List<XElement> mobiles = doc.Descendants("Mobile").ToList();
//mobiles = mobiles.Where(x => (string)x.Element("ID") == ID).ToList();
mobiles = mobiles.Where(x => (string)x.Attribute("ID") == ID).ToList();
doc.Descendants("Mobile").FirstOrDefault().ReplaceWith();
Best regards

How to process webdav server XML request in C#

I am writing a custom WebDAV server in C#. One of the client test programs I am using is NetDrive and it claims and appears to be a WebDAV compliant client. My problem is I am receiving a request on the server in the following format:
<?xml version="1.0" encoding="utf-8"?>
<propfind xmlns="DAV:">
<allprop/>
</propfind>
But other clients do this:
<?xml version="1.0" encoding="utf-8"?>
<D:propfind xmlns:D="DAV:">
<D:allprop/>
</D:propfind>
The two different namespace formats keep on fooing up my logic to look for the "allprop" element. My code looks a bit like this:
string xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><propfind xmlns=\"DAV:\"><allprop/></propfind>"; //Hardcode to make all the StackOverflow users' lives easier
XPathDocument doc = new XPathDocument(new StringReader(xml));
XPathNavigator nav = doc.CreateNavigator();
XPathNodeIterator it = nav.Select("/propfind/*");
Now, I know I need to put in some type of namespace manager for the "DAV:", so I tried this:
XmlNamespaceManager nsman = new XmlNamespaceManager(nav.NameTable);
nsman.AddNamespace("", "DAV");
XPathNodeIterator it = nav.Select("/propfind/*", nsman);
But I'm getting no nodes in my iterator for the first XML file. It seems the default namespace isn't working like I thought it should.
What am I doing wrong? How do I query this XML for the existence of an allprop node when the namespace may be the default, or may be explicitly named?
You are using the wrong namespace in your code. Unforunalely the WebDAV specs use
'DAV:' as the namespace for WebDAV nodes and attributes (this seems to be caused by
a missunderstanding of the XML namespace mechanism).
I ended up looking for the namespace URI (DAV:) and adding it if it didn't exist. Then I just did a namespace-qualified SELECT and it worked in all my test cases:
XPathDocument document = new XPathDocument(xml);
XPathNavigator navigator = document.CreateNavigator();
//Get namespaces & add them to the search
bool hasDAV = false;
string davPrefix = "D";
XmlNamespaceManager nsman = new XmlNamespaceManager(navigator.NameTable);
foreach (KeyValuePair<string, string> nskvp in navigator.GetNamespacesInScope(XmlNamespaceScope.All))
{
if (string.Compare(nskvp.Value, "DAV:", StringComparison.InvariantCultureIgnoreCase) == 0)
{
hasDAV = true;
davPrefix = nskvp.Key;
}
nsman.AddNamespace(nskvp.Key, nskvp.Value);
}
if (!hasDAV)
nsman.AddNamespace(davPrefix , "DAV:");
XPathNodeIterator iterator = navigator.Select("/" + davPrefix + ":" + WebDavXML.PropFind + "/*", nsman);

how to parse a XML in C# using NamspaceManager,XML is having namespaces defined at elements level

i wish to parse following XML
<?xml version="1.0" encoding="UTF-8"?>
<product xmlns="http://products.org">
<make xmlns="http://camera.org">
<model>Camry</model>
</make>
<make xmlns="http://tv.org">
<model>Sony</model>
</make>
</product>
Code written to parse it
This is how i m writing Parsing Code
but in last i m getting null inxmlNode object. Can u tell what more to do .
You can't ignore namespaces in XPath.* The elements in your document all have non-blank namespace URI's.
Your question title indicates you're on the right track: you need to explicitly bind the URI's to prefixes using an XmlNamespaceManager, and use those prefixes in your path expressions.
This program is tested against your input document
using System;
using System.Xml;
public class XPathNamespace
{
public static void Main() {
XmlDocument doc = new XmlDocument();
doc.Load("test1.xml");
XmlNamespaceManager xnm = new XmlNamespaceManager(doc.NameTable);
xnm.AddNamespace("p", "http://products.org");
xnm.AddNamespace("c", "http://camera.org");
xnm.AddNamespace("t", "http://tv.org");
ShowNode(doc.SelectSingleNode("/p:product", xnm));
ShowNode(doc.SelectSingleNode("/p:product/c:make", xnm));
ShowNode(doc.SelectSingleNode("/p:product/t:make", xnm));
}
private static void ShowNode(XmlNode node) {
Console.WriteLine("<{0}> {1}",
node.LocalName,
node.NamespaceURI);
}
}
and it produces the following output
<product> http://products.org
<make> http://camera.org
<make> http://tv.org
Hope this helps.
(*) This doesn't mean you can't ignore the exact namespace in your XPath. For example, you could match
/*[local-name()='product']
But that's a workaround and illustrates that you still have to deal with the presence of a namespace somehow or other.
This is the best example for you. Please have a look.
http://www.codeproject.com/KB/cpp/myXPath.aspx

"An object reference is required for the non-static field, method, or property"

i am stuck with this small problem in my code.
I am trying to make small console application which will write into xml document.
I have used xmldocument and xmlnode concept.
ERROR i am getting is;
*An object reference is required for the non-static field, method, or property 'Write_xml.Program.give_node(System.Xml.XmlDocument)' C:\Documents and Settings\Administrator\Desktop\Write_xml\Write_xml\Program.cs*
code is okay except 1 error. I am not able to resolve it ,i want somebody to check it and correct it.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
namespace Write_xml
{
class Program
{
static void Main(string[] args)
{
XmlDocument doc = new XmlDocument();
XmlDocument lets = new XmlDocument();
string path = #"D:\XMLFile.xml";
doc.Load(path);
XmlNode Rootnode = doc.SelectSingleNode("Number");
XmlNode TakenOde = give_node(doc);
Rootnode.AppendChild(TakenOde);
doc.Save(path);
}
public XmlNode give_node(XmlDocument lets)
{
// On this xmldoc we will perform XMLNODE operations
// for creat new nods and append child nodes
//XmlNode RootNode = xmldoc.CreateElement("Root");
XmlNode PersonsNode = lets.CreateElement("Person");
XmlNode NameNode = lets.CreateElement("Name");
PersonsNode.AppendChild(NameNode);
NameNode.InnerText = "1st";
XmlNode AgeNode = lets.CreateElement("Age");
PersonsNode.AppendChild(AgeNode);
AgeNode.InnerText = "2nd";
XmlNode CityNode = lets.CreateElement("City");
PersonsNode.AppendChild(CityNode);
CityNode.InnerText = "3rd";
return PersonsNode;
}
}
}
please let me what small mistake i am doing.
You're trying to call an instance method, but without specifying an instance.
The simplest fix for this is to make the give_node method static.
I haven't looked at the rest of the code to see whether it's okay or not, although give_node should be called GiveNode to follow .NET naming conventions.

Xml Attribute not showing up on ListBox - C#

I'm getting a null reference exception whenever it tries to add the packages titles info and other attributes but the attributes exist and the proper package is selected
Heres the code:
private void categorylist_listview_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
XmlDocument LoadPackageList = new XmlDocument();
//Removes the text "Select A Category" and refrehes the form
packagelist_listbox.Items.Remove(SelectaCategory_listbox);
if (categorylist_listview.SelectedItem == WWW_listviewitem)
{
LoadPackageList.Load("www.xml");
XmlNodeList WWWPackageList = LoadPackageList.SelectNodes("/Packages/*");
int countthenodes = 0;
foreach (XmlNode WWWPackages in WWWPackageList)
{
//Cycles through all the packages and assings them to a string then adds it to the packagelist
countthenodes++;
PackageTitle[countthenodes] = WWWPackages.Attributes["title"].ToString();
PackageInfo[countthenodes] = WWWPackages.Attributes["info"].ToString();
PackageDownloadUrl[countthenodes] = WWWPackages.Attributes["downloadurl"].ToString();
PackageTags[countthenodes] = WWWPackages.Attributes["tags"].ToString();
packagelist_listbox.Items.Add(PackageTitle[countthenodes]);
}
Refresh(packagelist_listbox);
}
}
It Errors out at PackageTitle[countthenodes] = WWWPackages.Attributes["title"].ToString();
XML File:
<Packages>
<Firefox title="Mozilla Firefox" tags="www firefox web browser mozilla" info="http://google.com" downloadurl="http://firefox.com"></Firefox>
</Packages>
The Variables are declared
public string[] PackageTags;
public string[] PackageTitle;
public string[] PackageInfo;
public string[] PackageDownloadUrl;
At the very beginning of the file
Well, the first problem is that calling ToString() on an XmlAttribute isn't going to do what you want. You should use the Value property. However, I don't believe that's causing a NullReferenceException unless the data isn't quite as you showed it. Here's a short but complete program which works fine:
using System;
using System.Xml;
class Test
{
static void Main()
{
XmlDocument doc = new XmlDocument();
doc.Load("test.xml");
XmlNodeList list = doc.SelectNodes("/Packages/*");
foreach (XmlNode node in list)
{
Console.WriteLine(node.Attributes["title"].Value);
}
}
}
That displays "Mozilla Firefox" with the XML you gave us.
Options:
Your real XML actually contains an element without a title attribute
Perhaps PackageTitle is null?
It would help if you could produce a short but complete program demonstrating the problem. Ideally it should avoid using a GUI - I can't see anything here which is likely to be GUI-specific.
If you could tell us more about PackageTitle and how it's being initialized, that would help too. How are you expecting it to just keep expanding for as many elements as you find? Or is it an array which is initialized to a larger size than you ever expect to find elements?

Categories

Resources